python

How to use virtualenv with Google App Engine SDK on Mac OS X 10.6

I am pulling my hair out trying to figure this out because I had it working until last week and somehow it broke. When I setup a virtualenv for a Google App Engine app and start the app with dev_appserver.py, I get errors importing the standard library (like "ImportError: No module named base64"). Here's what I'm doing: (Using the sy...

Python magical main() signature like Perl 6

Does python have any way to easily and quickly make CLI utilities without lots of argument parsing boilerplate? In perl6, the signature for the MAIN sub automagically parses command line arguments. Is there any way to do something similar in python without lots of boilerplate? If there is not, what would be the best way to do it? I'm t...

Python, get windows special folders for currently logged-in user

How can I get Windows special folders like My Documents, Desktop, etc. from my Python script? Do I need win32 extensions? It must work on Windows 2000 to Windows 7. ...

AppEngine no host given exception

Hello. I've got a Python app, that uses urllib.urlopen. It works fine on dev_appserver.py, but throws [Errno http error] no host given error on my GAE production server. The code is exactly the same, the url, it connects to, is hardcoded. I'm out of ideas, what could be wrong. UPD: the code: def getPic(url): sock = urllib.urlopen("...

Preventing window overlap in GTK

I've got a Python/Linux application that displays bits of info I need in a GTK window. For the purposes of this discussion, it should behave exactly like a dock - exists on all virtual desktops, and maximized windows do not overlap it. The first point is pretty easy, but I have spent days bashing my head against my monitor trying to ...

Choosing multicast network interface in Python.

I have a server with two separate Ethernet connections. When I bind a socket in python it defaults to one of the two networks. How do I pull a multicast stream from the second network in Python? I have tried calling bind using the server's IP address on the second network, but that hasn't worked. ...

How to add http headers in WSGI middleware?

How can http headers be added within a WSGI middleware? ...

create 2d array in python?

this is the code i am trying to create the 2d matrix m=4 tagProb=[[]]*(m+1) count=0 index=0 for line in lines: print(line) if(count < m+1): tagProb[index].append(line.split('@@')[2].strip()) count+=1 if(count == m+1): // this check to goto next index count = 0 index+=1 print(tagProb) i get ...

libgeos_c-1.dll can't be loaded by Python

I'm building my first GeoDjango project but I'm kinda desperate. I'v installed PostgreSQL 9 and PostGis 1.5 through one-click installer on Windows. So everthing is there. I set GEOS_LIBRARY_PATH to the full path of libgeos_c-1.dll in settings.py. But when I run manage.py syncdb, I encounter the following errors: File "C:\Python25\lib...

AES encryption library compatible with Python 2.7 for Windows

Any recommendations on an AES encryption library that's compatible with Python 2.7 for Windows? In the past we've used m2crypto with Python 2.6, but there's no version of m2crypto for Python 2.7 and our attempts to build a version from source have failed. Thank you, Malcolm ...

Handling HTTP/1.1 Upgrade requests in CherryPy

I'm using CherryPy for a web server, but would like it to handle HTTP/1.1 Upgrade requests. Thus, when a client sends: OPTIONS * HTTP/1.1 Upgrade: NEW_PROTOCOL/1.0 Connection: Upgrade I'd like the server to hand the connection off to some NEW_PROTOCOL handler after responding with the necessary HTTP/1.1 101 Switching Protocols..., as...

Better way to execute ruby file using Python and How to get ruby console output when ruby file is run from python?

Hi, I am building a standalone using python. This standaloone should execute a ruby file. I have read this article - http://www.decalage.info/python/ruby_bridge I have used os.system() which works well. But I have an issue here. If a ruby file has some error, file simply terminates without error. Can you please let me know how to GET r...

imageData function in OpenCV with Python

Hi, I am trying to make some transformations on an image with OpenCV and Python. I started by reading the image with cvLoadImage function, and then I got the image data with imageData function. img = highgui.cvLoadImage("x.png",1) data = img.imageData The problem is, the imageData function returns a string data and when I try to do s...

Themed progressbar for EasyDialogs or Python Win32's progressbar.py examples?

Looking for a way to have the native Windows progressbar implemented via EasyDialogs or Python Win32's progressbar.py example use the operating systems theme support so that the progressbar shows a modern user interface vs. something that's a throwback to Windows 95. I've tried compiling both these techniques as py2exe executables with ...

How do you bind Home/End to act like Cmd-Left/Cmd-Right in Eclipse on Mac?

Hi guys! This is my first question on SO, so please be gentle :) I've recently started a new job in which I do all of my development in PyDev on Eclipse 3.4.0 on OSX 10.6. Thus, I've been looking for a way to make Home and End act like they do on Windows (my native OS, and where I developed my muscle memory). I've mostly succeeded, b...

custom comparison for built-in containers

In my code there's numerous comparisons for equality of various containers (list, dict, etc.). The keys and values of the containers are of types float, bool, int, and str. The built-in == and != worked perfectly fine. I just learned that the floats used in the values of the containers must be compared using a custom comparison function...

Nautilus python

I'm developing a nautilus extension and I have the following code: #!/usr/local/bin/python # -*- coding: utf-8 -*- import urllib import gtk import pygtk import nautilus import gconf import gtk.glade class Slide (nautilus.MenuProvider): f = None def __init__(self): self.client = gconf.client_get_default() self....

How to parse and print fields from CSV data in python.

I'm dealing with an application that exports text as as CSV type data. The text is broken up into fields where there was a hard return. I have been trying to use pythons CSV to restore the text. This is an example of the text: {"This is an example", "of what I what I have to deal with. ", "Please pick up th following:", "eggs", "milk...

AppEngine: Query datastore for records with no condition for a specific property

i want to do a query that a user may or may not select a filter, but i don't want to create 2 indexes (tables). value=self.request.get('filter') if value: results=Entity.all().filter('p1 =','v1').filter('p2 =','v2').filter('filter_property =',value) else: results=Entity.all().filter('p1 =','v1').filter('p2 =','v2') i could ord...

is all the available swig+python+mingw compile information outdated?

I'm trying to build a C++ extension for python using swig. I've followed the instructions below and the others to a T and can't seem to get my extension to load. I ran across this article on the MinGW site under "How do I create Python extensions?" http://www.mingw.org/wiki/FAQ I also found these tutorials: http://boodebr.org/main/p...