python

Most efficient way to update attribute of one instance

Hi all - I'm creating an arbitrary number of instances (using for loops and ranges). At some event in the future, I need to change an attribute for only one of the instances. What's the best way to do this? Right now, I'm doing the following: 1) Manage the instances in a list. 2) Iterate through the list to find a key value. 3) Once I ...

How to compile a svn python binding for windows from the source?

I'm setting up a new svn+trac environment, the svn server's version is 1.6.11, then I can't find any corresponding pre-compiled svn-python binding, finally I found the following thread: http://stackoverflow.com/questions/677252/python-svn-bindings-for-windows so, my question is: how to compile from these source? http://svn.apache.org/...

send activate-email with django-registration

Hi All, I curius about how to send activated email with username, password by using django-registration. First I think about modify registrationform but I need some example. ...

Required Working Precision for the BBP Algorithm?

Hello, I'm looking to compute the nth digit of Pi in a low-memory environment. As I don't have decimals available to me, this integer-only BBP algorithm in Python has been a great starting point. I only need to calculate one digit of Pi at a time. How can I determine the lowest I can set D, the "number of digits of working precision"? ...

Check for a valid domain name in a string?

I am using python and would like a simple api or regex to check for a domain name's validity. By validity I am the syntactical validity and not whether the domain name actually exists on the Internet or not. ...

How to restrict the size of file being uploaded apache + django

Hi How to restrict the size of file being uploaded. I am using django 1.1 with apache. Can I use apache for this and show some html error page if say size is bigger then 100MB. Thanks. ...

Passing javascript variable to python

Hi, for example: #!/usr/bin/python print "This is python." print "<script type="text/javascript"> var pass_to_python = new Number(7) </script>" the_number = pass_to_python??? How do i get the pass_to_python in python? Thanks. ...

how to send authenticated email for every user ?

Hi, i have created two application,if user signed in one application,i have to sent authenticated email to the user but the link is for activating their account for another application.i.e)the user name and password for both the application is same for the particular user,instead of creating new user name and password for another ...

Up To Date Documentation on Wrapping gobjects with Python

I'm looking for up-to-date documentation and tutorials on creating Python bindings for gobjects. Everything I can find on the web is either incomplete or out of date. ...

which inotify event signals the completion of a large file operation?

for large files or slow connections, copying files may take some time. using pyinotify, i have been watching for the IN_CREATE event code. but this seems to occur at the start of a file transfer. i need to know when a file is completely copied - it aint much use if it's only half there. when a file transfer is finished and completed, w...

Google App Engine appcfg.py data_upload Authentication fail

Hi, I am using appcfg.py to upload data to datastore from a csv file. But every time I try, I am getting error: [info ] Authentication failed even if i am using Admin id and password. In my app.yaml file I am having: handlers: - url: /remote_api script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py login: admin -...

How to use python to create a GUI application which have cool animation/effects under Linux (like 3D wall in Cooliris, compiz effects etc...)

Hi, I am not sure if my question title makes sense to you or not. I am seeing many cool applications which have cool animations/effects. I would like to learn how to use python to create this kind of GUI applications under Linux. "cool animation/effects" like 3D wall in Cooliris which is written in flash and compiz effects with opengl....

prints line number in both txtfile and list????

i have this code which prints the line number in infile but also the linenumber in words what do i do to only print the line number of the txt file next to the words??? d = {} counter = 0 wrongwords = [] for line in infile: infile = line.split() wrongwords.extend(infile) counter += 1 for word in infile: if word not in d: d[...

Google App Engine - Help with running python shell comands from aptanna studio

Hi I'm somewhat of a newbie to python and I'm using app engine and aptanna studio - I need to run some python shell commands so that i can complete the tasks in this Tutorial on how to set up 118 and django. I have got this all working but i don't understand how i run the python commands to compile the dictionarys such as $ PYTHONPATH=/...

How do I get a GtkTreePath or GtkTreeIter to the last row in a GtkTreeModel?

I want to get a GtkTreePath or GtkTreeIter to the last row in a GtkTreeModel, but GtkTreeModel does not have a function for that. I'll be happy with answers and examples in either C, or Python, or both ;). ...

Python del() built-in can't be used in assignment?

I noticed a problem when I was trying to use del in a lambda to thin out a list of threads to just those running: map(lambda x: del(x) if not x.isAlive() else x, self.threads) Ignore for a second that this doesn't do anything, I'm just fooling around with map, reduce, and lambda. This fails with a syntax error at del(x). With some m...

Java code translation of Python array-splitting code

Can someone please give the Java equivalent of the below python (which slices a given array into given parts) which was originally written by ChristopheD here: def split_list(alist, wanted_parts=1): length = len(alist) return [ alist[i*length // wanted_parts: (i+1)*length // wanted_parts] for i in range(wanted_parts) ...

How to calculate cointegrations of two lists?

Hello everybody! Thank you in advance for your help! I have two lists with some stocks prices, example: a = [10.23, 11.65, 12.36, 12.96] b = [5.23, 6.10, 8.3, 4.98] I can calculate the correlation of these two lists, with: import scipy.stats scipy.stats.pearsonr(a, b)[0] But, I didn't found a method to calculate the co-integrat...

Python problem with resize animate GIF

Hello! I'm want to resize animated GIF with save animate. I'm try use PIL and PythonMagickWand (ImageMagick) and with some GIF's get bad frame. When I'm use PIL, it mar frame in read frame. For test, I'm use this code: from PIL import Image im = Image.open('d:/box_opens_closes.gif') im.seek(im.tell()+1) im.seek(im.tell()+1) im.seek...

How do you call function after client finishes download from tornado web server?

I would like to be able to run some cleanup functions if and only if the client successfully completes the download of a file I'm serving using Tornado. I installed the firefox throttle tool and had it slow the connection down to dialup speed and installed this handler to generate a bunch of rubbish random text: class CrapHandler(BaseH...