python

Django VMware appliance

Does anyone know of a Django 1.0 + postgresql + apache + mod_python VMware appliance? A "vanilla" Django 1.0 appliance where postgresql can be installed manually would also do. ...

Debug Pylons application through Eclipse

I have Eclipse setup with PyDev and love being able to debug my scripts/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp? ...

How do I manipulate bits in Python ?

In C I could, for example, zero out bit #10 in a 32 bit unsigned value like so: unsigned long value = 0xdeadbeef; value &= ~(1<<10); How do I do that in Python ? ...

Character reading from file in Python

In a text file, there is a string "I don't like this". However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'". I use f1 = open (file1, "r") text = f1.read() command to do the reading. Now, is it possible to read the string in such a way that wh...

In Django is there a way to display choices as checkboxes?

In the admin interface and newforms there is the brilliant helper of being able to define choices. You can use code like this: APPROVAL_CHOICES = ( ('yes', 'Yes'), ('no', 'No'), ('cancelled', 'Cancelled'), ) client_approved = models.CharField(choices=APPROVAL_CHOICES) to create a drop down box in your form and force the u...

Preserving signatures of decorated functions

Suppose I have written a decorator that does something very generic. For example, it might convert all arguments to a specific type, perform logging, implement memoization, etc. Here is an example: def args_as_ints(f): def g(*args, **kwargs): args = [int(x) for x in args] kwargs = dict((k, int(v)) for k, v in kwarg...

Using OR comparisons with IF statements

When using IF statements in Python, you have to do the following to make the "cascade" work correctly. if job == "mechanic" or job == "tech": print "awesome" elif job == "tool" or job == "rock": print "dolt" Is there a way to make Python accept multiple values when checking for "equals to"? For example, if job == "mec...

Caching in urllib2?

Is there an easy way to cache things when using urllib2 that I am over-looking, or do I have to roll my own? ...

Keeping GUIs responsive during long-running tasks

Hello, Keeping the GUI responsive while the application does some CPU-heavy processing is one of the challenges of effective GUI programming. Here's a good discussion of how to do this in wxPython. To summarize, there are 3 ways: Use threads Use wxYield Chunk the work and do it in the IDLE event handler Which method have you found ...

Is there a way to define which fields in the model are editable in the admin app?

Assume the following: models.py class Entry(models.Model): title = models.CharField(max_length=50) slug = models.CharField(max_length=50, unique=True) body = models.CharField(max_length=200) admin.py class EntryAdmin(admin.ModelAdmin): prepopulated_fields = {'slug':('title',)} I want the slug to be pre-populated by...

Opinions on DBCook?

Hi everyone! I'm looking for opinions on the DBCook framework as a declarative wrapper for SQLAlchemy.. Has anyone used it? Thanks for your time! ...

Background tasks on appengine

How to run background tasks on appengine ? ...

Python desktop widgets

I'm interested in making desktop widgets, similar to Apple's Dashboard or what Vista has. I'd like to make them cross-platform, if possible. Opera's widgets are cross-platform but require the user to have Opera installed, so that's a big limitation. I know most widgets are made with HTML/XML, CSS, and Javascript. Is there a way to creat...

BeautifulSoup's Python 3 compatibility

Does BeautifulSoup work with Python 3? If not, how soon will there be a port? Will there be a port at all? Google doesn't turn up anything to me (Maybe it's 'coz I'm looking for the wrong thing?) ...

Python v. Perl

Okay, so I'm finally making the jump into scripting languages and I have decided to focus on either Python or Perl. The problem is: I don't know which to cut my teeth on. Most of my programming experience is in C, Java, and C++. There's no specific task I would be learning Python/Perl for, other that possibly applying it to my dev work ...

What is the difference between __reduce__ and __reduce_ex__ ?

I understand that these methods are for pickling/unpickling and have no relation to the reduce built-in function, but what's the difference between the 2 and why do we need both? ...

How do you break into the debugger from Python source code?

What do you insert into Python source code to have it break into pdb (when execution gets to that spot)? ...

Send file using POST from a Python script

This is an almost-duplicate of http://stackoverflow.com/questions/68477/send-file-using-post-from-a-python-script, but I'd like to add a caveat: I need something that properly handles the encoding of fields and attached files. The solutions I've been able to find blow up when you throw unicode strings containing non-ascii characters into...

How Does One Read Bytes from File in Python

Similar to this question, I am trying to read in an ID3v2 tag header and am having trouble figuring out how to get individual bytes in python. I first read all ten bytes into a string. I then want to parse out the individual pieces of information. I can grab the two version number chars in the string, but then I have no idea how to ta...

Is there any Visual Library alternative to wxPython that supports CSS/Style Sheets?

Hi. I've developed a program that extensively uses wxPython - the wxWindow port for python. Even though it is as mature library it is still very primitive and very programming oriented. Which is time consuming and not flexible at all. I would love to see if there is something like Flex/Action Script where all the visual dimensions ar...