python

unbuffered urllib2.urlopen

I have client for web interface to long running process. I'd like to have output from that process to be displayed as it comes. Works great with urllib.urlopen(), but it doesn't have timeout parameter. On the other hand with urllib2.urlopen() the output is buffered. Is there a easy way to disable that buffer? ...

pythonic way to optimize the logic to filter/extract data from list

I have a list like below: ['1 (UID 3234 FLAGS (seen \\Seen))', '2 (UID 3235 FLAGS (\\Seen))', '3 (UID 3236 FLAGS (\\Deleted))', '4 (UID 3237 FLAGS (-FLAGS \\Seen +FLAGS))', '5 (UID 3241 FLAGS (-FLAGS \\Seen +FLAGS))', '6 (UID 3242 FLAGS (\\Seen))', '7 (UID 3243 FLAGS (\\Seen))', '8 (UID 3244 FLAGS (\\Seen))', '9 (UID 3245 FLAGS (\...

Allow hop-by-hop headers in Django proxy middleware

I need to implement a HTTP proxy in Django and my Google safari led me to a project called django-webproxy. Although no longer maintained, it's quite simple. Most of the logic relies on a simple proxy Middleware class that intercepts all requests to the Django WSGI server and handles it. If the Middleware returns any data, the WSGI se...

Neural network library for Python?

Can anyone (preferably with actual experience of the recommended library), suggest a good ANN library for Python? [Edit] ideally, the library/framework supports more than the basic FF paradigm. I would like one that has (or allows you to build) other network types e.g. a SO network for example ...

Python: how to make HTTP request internally/localhost

I want to send some parameters from a python script on my server to a php script on my server using HTTP. Suggestions? ...

python RSA module how to use java decrypt

I use python rsa module(http://stuvel.eu/rsa) get private_key and public_key. How can I use these private_key and public_key to encrypt or decrypt in java? ...

SpringPython error following the book: AttributeError: 'module' object has no attribute 'ObjBase'

Hello from Spain. Well, I bought the book Spring Python 1.1 and I have been facing some problems that I cannot solve. I am going to write the code of each file in order to make sure everything is clear. If some of you know what is the problem, please let me know because I am desperate. simple_service.py class Service(object): def happ...

Get all Request headers in Django

I need to get all the Django request headers. From what i've read, Django simply dumps everything into the request.META variable along with a lot aof other data. What would be the best way to get all the headers that the client sent to my Django application? I'm going use these to build a httplib request. Thank you. ...

python code highlighter for publishing in html

Hello, everyone I'm looking for a python code highlighter for publishing as html. I've found this site http://quickhighlighter.com that does highlighting really well. However if I try to copy/paste some python code from it to a text file, I get a mess. If you know a better tool, please let me know. Thanks in advance. ...

Why is tempfile using DOS 8.3 directory names on my XP box?

>>> import tempfile >>> tempfile.mkstemp() (3, 'c:\\docume~1\\k0811260\\locals~1\\temp\\tmpk6tpd3') It works, but looks a bit strange. and the actual temporary file name is more than 8 letters. Why doesn't it use long file names instead? ...

How to stream my webcam through my site?

Is it possible to stream my webcam form my local machine that's connected to the internet to show up on my website without using any media server or something similar? ...

Filtering of an Object's property's property in google app engine

In an App Engine app, I store registered members in a table that looks like this: class Member(db.Model): user = db.UserProperty(required=True) #other stuff The problem starts when I need to check if a User is already in my Member table. GAE documentation says user value is not guaranteed not to change in time since it is comp...

How is generated the python grammar and how the interpreter understand it

I wonder how is generated the grammar of the Python language and how it is understood by the interpreter. In python, the file graminit.c seems to implement the grammar, but i don't clearly understand it. More broadly, what are the different ways to generate a grammar and are there differences between how the grammar is implemented in l...

Python to javascript communication

OK so im using websockets to let javascript talk to python and that works very well BUT the data i need to send often has several parts like an array, (username,time,text) but how could i send it ? I originally though to encode each one in base64 or urlencode then use a character like | which those encoding methods will never use and the...

How do I use num_rows() function in the MySQLDB API for Python?

I have this statement cursor = connection.cursor() query = "SELECT * from table" cursor.execute(query) res = cursor.fetchall() ...

quick question: clear an attribute of a model in django

hello everybody! i think this is a pretty easy question for you. I want to clear an attribute of a django-model. If i have something like this: class Book(models.Model): name = models.TextField() pages = models.IntegerField() img = models.ImageField() In an abstract function i want to clear an attribute, but a...

Matrix multiplication in numpy

Hi, The numpy docs recommend using array instead of matrix for working with matrices. However, unlike octave (which I was using till recently), * doesn't perform matrix multiplication, you need to use the function matrixmultipy(). I feel this makes the code very unreadable. Does anybody share my views, and has found a solution? Thanks...

Jabber bot - how to get the availability of contacts?

I need to set up a jabber bot, using python, that will send messages based on the online/offline availability of several contacts. I've been looking into pyxmpp and xmpppy, but couldn't find any way (at least nothing straightforward) so check the status of a given contact. Any pointers on how to achieve this? Ideally I would like some...

django - 404 page displayed for dev web server (http://127.0.0.1:8000/)

I am familiarizing my self with django. I have succesfully installed and tested a demo site. I now want to switch on the admin module, to see what happens. This is the steps I took (granted, some were unnecessary, but I just wanted to make sure I was starting from a clean slate): Edited mysite/settings.py to enable admin Edited mysit...

Select cells randomly from NumPy array - without replacement

I'm writing some modelling routines in NumPy that need to select cells randomly from a NumPy array and do some processing on them. All cells must be selected without replacement (as in, once a cell has been selected it can't be selected again, but all cells must be selected by the end). I'm transitioning from IDL where I can find a nice...