python

ensuring dynamic image urls in a web-app: use a blob store?

I want to serve images in a web-app using sessions such that the links to the images expire once the session has expired. If I show the actual links to the filesystem store of the images, say http://www.mywebapp.com/images/foo1.jpg this clearly makes stopping future requests for the image (one the user has signed out of the session) dif...

textmate >> vim for python - teething troubles: especially indenting

I'm (attempting) to move from textmate to vim [macvim to be exact] as my primary editor. I have already installed snipmate - wondering if there are other plugins you would suggest I install? In particular I seem to be having a lot of trouble with indenting (<< seems to really do some very strange/unpredictable things), and I can't seem ...

How to call a self.value in a class function definition in python?

How could I call a self.value in a definition of a function? class toto : def __init__(self): self.titi = "titi" def printiti(self,titi=self.titi): print(titi) ...

Check if passwordless access has been setup

Hello, I would test via a python script whether a passwordless ssh login has been setup or not. If i run the normal ssh command then it will wait to accept the password for some amount of time. Is there a way where the ssh command should return an error as soon as ssh asks for a password. Is it possible to achieve this? ...

dynamic values in kwargs

I have a layer which helps me populating records from the form to tables and viceversa, it does some input checking, etc. Now several methods of this layer which are called several times in different parts of the webform take the same parameters, so I wanted to pack them at the begining of the codefile. kwargs(): return {"tabla"...

Check memory usage of subprocess in Python

Hi all, I'm developing an application in Python on Ubuntu and I'm running external binaries from within python using subprocess. Since these binaries are generated at run time and can go rogue, I need to keep a strict tab on the amount of memory footprint and runtime of these binaries. Is there someway I can limit or monitor the memory u...

Is there a more elegant / pythonic way to express this construct?

itemList = ["a","b","c","d","e","f","g","h"] aa = "NULL" bb = "NULL" cc = "NULL" for item in itemList: aa = bb bb = cc cc = item if aa == "NULL": continue print "%s_%s_%s" % (aa, bb, cc) ...

problem with python xgoogle library. How to increase the limit of 10 results?

I use http://www.catonmat.net/blog/python-library-for-google-search/ to make queries at Google search engine but the number of results I get is limited to 10. I used the results_per_page property and I set it to 50, 100 etc. but the number of results didn't changed. Is there a way to get more results? Is there another python lib without ...

Task fanout - how to bulk add Tasks to the Queue - more than 5

I am using a task (queueing-task) to queue multiple others tasks — fanout. When I try to use Queue.add with task argument being a list of Task instances with more than 5 element's and in transaction… I get this error. JointException: taskqueue.DatastoreError caused by: <class 'google.appengine.api.datastore_errors.BadRequestError'...

MT940 format parser

Can you recommend any OS, ready-to-go, well-documented and not dead MT940 format parser for Python? ...

mod_python Apache configuration

I am having issues with getting my Mod Python to work properly. I have followed mod_python manual found here So here is my Apache setup (I am using Virtual Hosts): <VirtualHost *:80> ServerName hostname DocumentRoot "C:/Documents and Settings/username/hostname/www" <Directory "C:/Documents and Settings/username/hostname">...

Advanced sorting criteria for a list of nested tuples

I have a list of nested tuples of the form: [(a, (b, c)), ...] Now I would like to pick the element which maximizes a while minimizing b and c at the same time. For example in [(7, (5, 1)), (7, (4, 1)), (6, (3, 1))] the winner should be (7, (4, 1)) Any help is appreciated. ...

New to Python: Replacing a string by its position in a line

Let's say I got a file with three lines of this structure: foo Black sheep: 500 bar What I'd like to do is an iteration to change "Black sheep: 500" to 600, 700 and so on, replacing the old one. I can think of a way of doing it by search&replace, but I'm looking for a more elegant way by replacing a certain position (here pos.3) withi...

matplotlib pyplot colorbar question

Dear all, I'm trying to perform a scatter plot with color with an associated color bar. I would like the colorbar to have string values rather than numerical values, as I'm comparing two different data sets each one with different colorvalues (but in any case between a maximum and minimum values). Here the code I'm using import matplotl...

How can I retrieve a Google Talk users Status Message

I'd like to be able to retrieve a users Google Talk Status Message with Python, it's really hard to find documentation on how to use some of the libraries out there. ...

Simple ListBox w/ PyGTK Issues

Environment: PyGTK Glade Problem: After following several tutorials detailing how to get a ListBox up and running using the GtkTreeView widget alongside a gtk.ListStore object I still can't seem to get my data from the ListStore to show up in the GtkTreeView. Request: Anyone have a link to a thorough tutorial I can follow or willin...

Printing negative values as hex in python

I have the following code snippet in C++: for (int x = -4; x < 5; ++x) printf("hex x %d 0x%08X\n", x, x); And its output is hex x -4 0xFFFFFFFC hex x -3 0xFFFFFFFD hex x -2 0xFFFFFFFE hex x -1 0xFFFFFFFF hex x 0 0x00000000 hex x 1 0x00000001 hex x 2 0x00000002 hex x 3 0x00000003 hex x 4 0x00000004 If I try the same thing in...

What's BLUE from CCP Stackless presentations?

In Stackless Python in Eve, there is some talk about "BLUE" objects in Python. Does anyone know details about this technology? ...

How to search the correct directory for imports

I am trying to test some code. The main script requires imports from a number of subdirectories. The structure of the scripts is like this (I edited it to make it clear that dir1 and 2 are subdirectories of build): build ascript.py dir1 script2.py dir2 script3.py subdir1 script4.py script5.py subdir2 ...

how to change the color of a single bar if condition is True matplotlib

Hi guys! I've been googleing to find if it's possible to change only the color of a bar in a graph made by matplotlib. Imagine this graph: let's say I've evaluation 1 to 10 and for each one I've a graph generate when the user choice the evaluation. For each evaluation one of this boys will win. So for each graph, I would like to leav...