python

Handling missing packages or DLLs in a PyQt app

What's a good way to handle fatal errors - missing packages, .ui files not compiled, Qt DLLs or shared objects not found, etc. - in a PyQt app (or other Python app)? Displaying a cross-platform message box without Qt DLLs or shared objects seems like a lot of work. Dumping a message to the console seems not very helpful, since the end ...

python dictionary is thread safe ?

Some stated that python dictionary is thread safe. Does it mean I can or cannot modified the items in a dictionary while iterating over it? ...

Is Python good for writing standard, compatible and complete SOAP web services?

I have used few python soap libraries (SOAPpy, soaplib and Twisted wrapper around SOAPpy) to write my soap web service. When I used python clients (SOAPpy.SOAPProxy and SUDS), I was able to communicate with my web service (returning simple and complex type objects). But, when I tried with C# ASP.net, I got many issues. I came over retu...

how to set up python web dev environment

the set the i have so far is: windows 7 64bit Apache 2.2.14/mysql/php 5.3.1 i installed python 2.7. not configured. i tried installing mod_python but it kept telling python 2.5 is required ...

How do I create / access dynamic form fields in Django from within a View?

Hello, I have a system which keeps lots of "records" and need to integrate a component which will produce reports of any selected records. To the user, it looks like this: Click "Create Report" Select the records to be included in the report. Hit "Submit" and the report is displayed. To me I think: Load all records. Create a Repo...

How can I get html content from a brower that can do the html correction and js scripting?

Now I need a solution for getting HTML content from a browser. As rendering in a browser, js will be ran, and if not, js won't be ran. So any html libraries like lxml, beautifulsoup and others are all not gonna work. I've searched a project named pywebkitgtk, but it's purpose is to create a browser with a front end. Is there any way to p...

How can I remove all elements matching an xpath in python using lxml?

So I have some XML like this: <bar> <foo>Something</foo> <baz> <foo>Hello</foo> <zap>Another</zap> <baz> <bar> And I want to remove all the foo nodes. Something like this doesn't work params = xml.xpath('//foo') for n in params: xml.getroot().remove(n) Giving ValueError: Element is not a child of this node. Wha...

Python - Assign global variable to function return requires function to be global?

So, I'm confused. I have a module containing some function that I use in another module. Imported like so: from <module> import * Inside my module, there exist functions whose purpose is to set global variables in the main program. Some of the global variables need to be assigned to the output of another function in that same module....

Dynamically Created Top Articles List in Django?

I'm creating a Django-powered site for my newspaper-ish site. The least obvious and common-sense task that I have come across in getting the site together is how best to generate a "top articles" list for the sidebar of the page. The first thing that came to mind was some sort of database column that is updated (based on what?) with ev...

GUI in python programing

the fallowing is a tic tak toe game code in python, can some one show me how i can make it in GUI form with a reset option and shows who wins at the end. like X win or O win? board = " 1 | 2 | 3\n-----------\n 4 | 5 | 6\n-----------\n 7 | 8 | 9" . checkboard=[1,2,3,4,5,6,7,8,9,1,4,7,2,5,8,3,6,9,1,5,9,3,5,7] spaces=range(1,10) def mo...

Pylons 1.0 - c.id no longer being automatically set on python v2.6.2 and 2.7

I am at a loss on this one, I intalled a SSD on my dev box today and started with a fresh development environment. In short, pylons no longer sets the c.id based on the id passed to the action. Code, error, and libs install: http://pastie.org/1064929 Very strange, because my production server is mirroring my python version (2.6.2) and...

Doing an XSL transform of a branch of a Docbook element tree

I'd like to use the docbook XSL stylesheets to render various parts of a document, without transforming the entire thing. The complication is that some of these parts have <footnoteref> elements whose linkend attributes are not located within the same chunk. In other words, I want to process a branch of the tree which includes the <foo...

How to create a table and its related model.py automatically from a csv file in Django

Think of this: You create a CMS of some sort, which asks you for an application name and a csv file for that application. Then it automatically creates that app on the fly, creates the required model.py based on the csv columns, activates the admin page for it and allows only you to have the full permission to this new table via django ...

subprocess unable to capture STDOUT - what could be program be doing?

I have this program, which when executed on the console like this: prog 1> output 2> error Has the valid output and error. However, when I execute the same program using the subprocess module. p = subprocess.Popen(['prog'],stdout=PIPE, stderr=PIPE,close_fds=True) out, err = p.communicate() The out is empty but err is proper. What ...

Python string split

what would be the best way to split this in python. (address, city, state, zip) <div class="adtxt">7616 W Belmont Ave<br />Chicago, IL 60634-3225</div> in some case zip code is as <div class="adtxt">7616 W Belmont Ave<br />Chicago, IL 60634</div> ...

pydev eclipse configuration for __builtins__ ?

suppose on init I've install my function under builtins then throughout my project I can access it directly that function, no need to import, but how can I tell this to eclipse - so it should not show RED Error "undefined variable" __builtins__['_'] = gettext.gettext ...

A web crawler in python. Where should i start and what should i follow? - Help needed

I have an intermediate knowledge in python. if i have to write a web crawler in python, what things should i follow and where should i begin. is there any specific tut? any advice would be of much help.. thanks ...

Cannot Display an Image in Tkinter

When I run the program the canvas shows up but the Image does not. canvas = Canvas(frame, width = 128, height = 128, bg= 'white') image_data = Image.open('NoArt.gif') ppm_f = ImageTk.PhotoImage(image_data) canvas.create_image(0, 0, image = ppm_f, anchor = NW) canvas.pack(side=BOTTOM) any Ideas?? PS. I have PIL ver...

Python: multiple files download by turn

In script loop performs files downloading and saving (curl). But loop iterations too quick, so downloading and saving actions have no time to complete it's operations. Thereat result files comes broken def get_images_thread(table): class LoopThread ( threading.Thread ): def run ( self ): global db c=...

How to organise the file structure of my already working plugin system?

I am working on a project whose main design guiding principle is extensibility. I implemented a plugin system by defining a metaclass that register - with a class method - the class name of any plugin that gets loaded (each type of plugin inherit from a specific class defined in the core code, as there are different types of plugins in ...