python

I want to load all of the unit-tests in a tree, can it be done?

I have a heirarchical folder full of Python unit-tests. They are all importable ".py" files which define TestCase objects. This folder contains thousands of files in many nested subdirectories and was written by somebody else. I do not have permission to change it, I just have to run it. I want to generate a single TestSuite object whic...

Python Imaging Library save function syntax

Simple one I think but essentially I need to know what the syntax is for the save function on the PIL. The help is really vague and I can't find anything online. Any help'd be great, thanks :). ...

What's Python good practice for importing and offering optional features?

I'm writing a piece of software over on github. It's basically a tray icon with some extra features. I want to provide a working piece of code without actually having to make the user install what are essentially dependencies for optional features and I don't actually want to import things I'm not going to use so I thought code like this...

Getting return values from a MySQL stored procedure in Python, using MySQLdb

I've got a stored procedure in a MySQL database that simply updates a date column and returns the previous date. If I call this stored procedure from the MySQL client, it works fine, but when I try to call the stored procedure from Python using MySQLdb I can't seem to get it to give me the return value. Here's the code to the stored pr...

What's the fastest way to test the validity of a large number of well-formed URLs

My project requires me to validate a large number of web URLs. These URLs have been captured by a very unreliable process which I do not control. All of the URLs have already been regexp validated and are known to be well-formed. I also know that they all have valid TLDs I want to be able to filter these URLs quickly in order to determi...

How do you set a Tkinter frame size?

This is the code that's giving me trouble. f = Frame(root, width=1000, bg="blue") f.pack(fill=X, expand=True) l = Label(f, text="hi", width=10, bg="red", fg="white") l.pack() If I comment out the lines with the Label, the Frame displays with the right width. However, adding the Label seems to shrink the Frame down to the Label's si...

How can I check the memory usage of objects in ipython?

Duplicate http://stackoverflow.com/questions/33978/find-out-how-much-memory-is-being-used-by-an-object-in-python I am using ipython to run my code. I wonder if there is any module or command which allow me to check the memory usage of an object. For instance: 1> a = range(10000) 2> %memusage a 1MB Something like %memusage and r...

Python generators and co-routines.

Can someone provide me with a brief introduction on how to use Python generators to implement coroutines? ...

Anybody tried mosso CloudFiles with Google AppEngine?

I'm wondering if anybody tried to integrate mosso CloudFiles with an application running on Google AppEngine (mosso does not provide testing sandbox so I cann't check for myself without registering)? Looking at the code it seems that this will not work due to httplib and urllib limitations in AppEngine environment, but maybe somebody has...

What is a good & free game engine?

For C++, Java, or Python, what are some good game + free game engines that are easy to pick up? Any type of game engine is okay. I just want to get started somewhere by looking into different game engines and their capabilities. ...

Python - ConfigParser throwing comments

Hi, Based on ConfigParser module how can I filter out and throw every comments from an ini file? import ConfigParser config = ConfigParser.ConfigParser() config.read("sample.cfg") for section in config.sections(): print section for option in config.options(section): print option, "=", config.get(section, option) eg. ...

Is there a way to change effective process name in Python?

Can I change effective process name of a Python script? I want to show a different name instead of the real name of the process when I get the system process list. In C I can set strcpy(argv[0],"othername"); But in Python argv[0] = "othername" doesn't seem to work. When i get process list (with ps ax in my linux box) the real name...

can my programs access more than 4GB of memory?

if I run python on a 64bit machine with a 64bit operating system, will my programs be able to access the full range of memory? I.e. Could I build a list with 10billion entries, assuming I had enough RAM? If not, are there other programming languages that would allow this? ...

Setting values to the output of a formset in Django

This question is somewhat linked to a question I asked previously: http://stackoverflow.com/questions/477183/generating-and-submitting-a-dynamic-number-of-objects-in-a-form-with-django I'm wondering, if I've got separate default values for each form within a formset, am I able to pre-populate the fields? For instance, a form requiring ...

Using jep.invoke() method

Hi, I need to call a function from a python script and pass in parameters into it. I have a test python script which I can call and run from java using Jepp - this then adds the person. Eg Test.py import Finding from Finding import * f = Finding() f.addFinding("John", "Doe", 27) Within my Finding class I have addFinding(firstname...

Parsing HTML generated from Legacy ASP Application to create ASP.NET 2.0 Pages

One of my friends is working on having a good solution to generate aspx pages, out of html pages generated from a legacy asp application. The idea is to run the legacy app, capture html output, clean the html using some tool (say HtmlTidy) and parse it/transform it to aspx, (using Xslt or a custom tool) so that existing html elements, ...

How can I anonymise XML data for selected tags?

My question is as follows: I have to read a big XML file, 50 MB; and anonymise some tags/fields that relate to private issues, like name surname address, email, phone number, etc... I know exactly which tags in XML are to be anonymised. s|<a>alpha</a>|MD5ed(alpha)|e; s|<h>beta</h>|MD5ed(beta)|e; where alpha and beta refer to any c...

python code for django view

MODEL: class Pathology(models.Model): pathology = models.CharField(max_length=100) class Publication(models.Model): pubtitle = models.TextField() class Pathpubcombo(models.Model): pathology = models.ForeignKey(Pathology) publication = models.ForeignKey(Publication) List of pathology sent to HTML template as drop dow...

How can I make this one-liner work in DOS?

python -c "for x in range(1,10) print x" I enjoy python one liners with -c, but it is limited when indentation is needed. Any ideas? ...

Building a "complete" number range w/out overlaps

Hey, I need to build a full "number range" set given a series of numbers. I start with a list such as : ID START * 0 a 4 b 70 c 700 d 701 e 85 where "def" is the default range & should "fill-in" the gaps "overlaps" are value (70, 700, 701) in starting data And need the following result: ID ST...