python

Convert http headers (string) to a python dictionary

Is there a standard function that will convert http headers into a python dictionary, and one to convert back? They would need to support header folding, of course. ...

QtDesigner or doing all of the Qt boilerplate by hand?

When starting up a new project, as a beginner, which would you use? For example, in my situation. I'm going to have a program running on an infinite loop, constantly updating values. I need these values to be represented as a bar graph as they're updating. At the same time, the GUI has to be responsive to user feedback as there wil...

python glib main loop: delaying until loop is entered

Is there a way to schedule the execution of a callable until the glib main loop is entered? Alternatively, is there a signal I can subscribe to that will indicate that the main loop is entered? ...

Python UTF-16 WAVY DASH encoding question / issue

Hi. I was doing some work today, and came across an issue where something "looked funny". I had been interpreting some string data as utf-8, and checking the encoded form. The data was coming from ldap (Specifically, Active Directory) via python-ldap. No surprises there. So I came upon the byte sequence '\xe3\x80\xb0' a few times, which...

How do I get my simple twisted proxy to work?

I am attempting to make use of the Twisted.Web framework. Notice the three line comments (#line1, #line2, #line3). I want to create a proxy (gateway?) that will forward a request to one of two servers depending on the url. If I uncomment either comment 1 or 2 (and comment the rest), the request is proxied to the correct server. However,...

Django: Template context processor request variable

Hello, I am trying to implement django-facebookconnect, for I need to check if a user logged in via Facebook or a regular user. At the template, I can check if user logged in via facebook by checking request.facebook.uid such as: {% if is_facebook %} {% show_facebook_photo user %} {% endif %} For this, I need to pass is_facebook': re...

Package module not found in Python 2.5, but found in 2.6

I have package structure that looks like this: ae util util contains a method mkdir(dir) that, given a path, creates a directory. If the directory exists, no error is thrown; the method fails silently. The directory ae and its parent directory are both on my PYTHONPATH. When I try to use this method in Python 2.6, everything is ...

Why can't I do this INSERT in MYSQL? (Python MySQLdb)

This is a follow up to this question I asked earlier: http://stackoverflow.com/questions/2267034/why-cant-i-insert-into-mysql/2267076#2267076 That question solved it partly. Now I'm doing it in Python and it's not working :( cursor.execute("INSERT INTO life(user_id, utm) values(%s,PointFromWKB(point(%s,%s)))",the_user_id, utm_easting,...

Python, int to hex string

I want to take an integer (that will be <= 255), to a hex string representation eg: I want to pass in 65 and get out '\x65', or 255 and get '\xff' I've tried doing this with the struct.pack('c', 65), but that chokes on anything above 9 since it wants to take in a single character string. Thanks, ...

Low Autocorrelation Binary Sequence problem? Python troubleshooting..

I'm trying to model this problem (for details on it, http://www.mpi-hd.mpg.de/personalhomes/bauke/LABS/index.php) I've seen that the proven minimum for a sequence of 10 digits is 13. However, my application seems to be getting 12 quite frequently. This implies some kind of error in my program. Is there an obvious error in the way I'v...

Why does Sphinx generate json?

I notice that Sphinx has the ability to generate documentation in JSON. What are these files used for? ...

Extracting numerical value from Python Decimal

When I use the python Decimal object simply with something like: from decimal import * dec = Decimal('3.432') print dec it will print 3.432, just like I want, but if i try to put that same value dec into a json object what I get in the json is Decimal("3.432"). How can I just get the numerical value from decimal? ...

Syntax error after uploading GAE Python app

I have created a GAE app that parses RSS feeds using cElementTree. Testing on my local installation of GAE works fine. When I uploaded this app and tried to test it, I get a SyntaxError. The error is : Traceback (most recent call last): File "/base/python_lib/versions/1/google/appengine/ext/webapp/init.py", line 509, in call ...

Cannot bind to address after socket program crashes

If my program crashes before a socket is closed, the next time I run in, I get an error that looks like this; socket.error: [Errno 48] Address already in use Changing the port fixes the problem. Is there any way to avoid this, and why does this happen (when the program exits, shouldn't the socket be garbage collected, and closed)? ...

Finding the version of an application from Python?

Basically i am trying to find out what version of ArcGIS the user currently has installed, i looked through the registry and couldn't find anything related to a version string. However i know it is stored, within the .exe. I've done a fair bit of googling, and can't find anything really worth it. I tried using the GetFileVersionInfo, a...

How to customize the auth.User Admin page in Django CRUD ?

Hello, I just want to add the subscription date in the User list in the Django CRUD Administration site. How can I do that ? Thank you for your help ...

Subscription web/desktop app [PYTHON]

Hi, Firstly pardon me if i've yet again failed to title my question correctly. I am required to build an app to manage magazine subscriptions. The client wants to enter subscriber data and then receive alerts at pre-set intervals such as when the subscription of a subscriber is about to expire and also the option to view all subscriber ...

Create a Reg Exp to search for __word__?

In a program I'm making in python and I want all words formatted like __word__ to stand out. How could I search for words like these using a regex? ...

Hudson unable to navigate relative directories

I have a Python project building with Hudson. Most unit tests work correctly, but any tests that require writing to the file system (I have a class that uses tarfiles, for example) can't find the tmp directory I have set up for intermediate processing (my tearDown methods remove any files under the relative tmp directory). Here is my p...

Getting the name which is not defined from NameError in python.

Hello! As you know, if we simply do: >>> a > 0 Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> a > 0 NameError: name 'a' is not defined Is there a way of catching the exception/error and extracting from it the value 'a'. I need this because I'm evaluating some dynamically created expressions, and woul...