I have a class:
class AccountTransaction(db.Model):
account = db.ReferenceProperty(reference_class=Account)
tran_date = db.DateProperty()
debit_credit = db.IntegerProperty() ## -1, 1
amount = db.FloatProperty()
comment = db.StringProperty()
pair = db.SelfReferenceProperty()
so, what I want is to make a Save() m...
I've got a python script that runs just fine on my local machine, but as soon as I put it on our server, it dies horribly. It takes nearly two minutes to run, and utilizes 100% cpu while it's doing it.
I've narrowed it down to the paramiko library (it doesn't do it when I comment that out), but now I'm stumped. How is my server configur...
Hello,
I have to do an assignment where i have a .txt file that contains something like this
p
There is no one who loves pain itself, who seeks after it and wants to
have it, simply because it is pain...
h1
this is another example of what this text file looks like
i am suppose to write a python code that parses this text file and c...
I'm writing a web application using pylons and paste. I have some work I want to do after an HTTP request is finished (send some emails, write some stuff to the db, etc) that I don't want to block the HTTP request on.
If I start a thread to do this work, is that OK? I always see this stuff about paste killing off hung threads, etc. Will...
I've got a couple of projects where it would be useful to be able to interact with an SVN server from appengine.
Pull specific files from the svn (fairly easy, since there is a web interface which I can grab the data off automatically, but how do I authenticate)
Commit changes to the svn (this is the really hard/important part)
Possibl...
In this question, it was suggested that calling repr on a dictionary would be a good way to store it in another dictionary. This would depend on repr being the same regardless of how the keys are ordered. Is this the case?
PS. the most elegant solution to the original problem was actually using frozenset
...
I'm trying to learn object oriented programming, but am having a hard time overcoming my structured programming background (mainly C, but many others over time). I thought I'd write a simple check register program as an exercise. I put something together pretty quickly (python is a great language), with my data in some global variables...
Is there a built in function in python which will convert a binary string, for example '111111111111', to the two's complement integer -1?
...
I am using the Python/C API with my app and am wondering how you can get console output with a gui app. When there is a script error, it is displayed via printf but this obviously has no effect with a gui app. I want to be able to obtain the output without creating a console. Can this be done?
Edit - Im using Windows, btw.
Edit - The P...
I'm trying to compile my python script into a single .exe using gui2exe (which uses py2exe to create a .exe). My program is using wxWidgets and everytime I try to compile it I get the following error message:
error MSVCP90.dll: No such file or directory.
I have already downloaded and installed the VC++ redistributable package, so ...
I have an app that uses the python/c api and I was wondering what files I need to distribute with it? The app runs on Windows and links with libpython31.a Are there any other files? I tried the app on a seperate Win2k system and it said that python31.dll was needed so theres at least one.
Edit - My app is written in C++ and uses the Pyt...
In Python, if I multiply of list of objects by an integer, I get a list of references to that object, e.g.:
>>> a = [[]] * 3
>>> a
[[], [], []]
>>> a[0].append(1)
>>> a
[[1], [1], [1]]
If my desired behavior is to create a list of copies of the original object (e.g. copies created by the "copy.copy()" method or something sort of stand...
My server comes with one primary and five additional IP addresses. By default, urllib2 requests are all from primary IP addresses. How can I bind those secondary IP addresses to urllib2 with every reqeust it makes.
...
In my python code, I use the fileinput module for inplace replacing:
import fileinput
for line in fileinput.FileInput("permission.txt",inplace=1):
line = line.strip()
if not 'def' in line:
print line
else:
line=line.replace(line,'zzz')
print line
fileinput.close()
However, once it is done, permis...
I want to grab the color of a pixel with known coordinates on my Linux desktop.
Until now, I've used "import -window SomeWindow -crop 1x1+X+Y /tmp/grab.jpg"
then extracting the pixel value using Python and PIL.
This does the job, but since import grabs the whole window before cropping, it's very slow :(
Are there any clever way to gra...
I tried these two methods:
os.system("python test.py")
subprocess.Popen("python test.py", shell=True)
Both approaches need to wait until test.py finishes which blocks main process. I know "nohup" can do the job. Is there a Python way to launch test.py or any other shell scripts and leave it running in background?
Suppose test.py is ...
Hello,
I have recently updated my model, added a BooleanField to it however when I do python manage.py syncdb, it doesn't add the new field to the database for the model. How can I fix this ?
...
django.utils.translation.get_language() returns default locale if translation is not activated. Is there a way to find out whether the translation is activated (via translation.activate()) or not?
...
I'm using all of them to print the names of assigned IANA values in a packet. So all of the dictionaries have the same default value "RESERVED".
I don't want to use d.get(key,default) but access dictionaries by d[key] so that if the key is not in d, it returns the default (that is same for all dictionaries).
I do not necessarily need ...
I know of NLTK. What else is there that complements this library? Or can do AI?
NLTK is great because I can learn it with the book that it came out.
Is there a library for AI just like this?
...