I have a model where tasks are pieces of work that each may depend on some number of other tasks to complete before it can start. Tasks are grouped into jobs, and I want to disallow dependencies between jobs. This is the relevant subset of my model:
class Job(models.Model):
name = models.CharField(max_length=60, unique=True)
class ...
I've been writing a lot of constructs like this the past couple of days:
list = get_list()
if list:
for i in list:
pass # do something with the list
else:
pass # do something if the list was empty
Lot of junk and I assign the list to a real variable (keeping it in memory longer than needed). Python has simplified a lot...
I've been search for quite a while with no success. My project isn't using Django, is there a simple way to serialize App Engine models (google.appengine.ext.db.Model) into JSON or do I need to write my own serializer? My model class is fairly simple. For instance:
class Photo(db.Model):
filename = db.StringProperty()
title = d...
Is it possible to yank an entire block of python code in vim? be it a def, for, if, etc. block..
...
This is a normal case of mutual import. Suppose you have the following layout
./test.py
./one
./one/__init__.py
./one/two
./one/two/__init__.py
./one/two/m.py
./one/two/three
./one/two/three/__init__.py
./one/two/three/four
./one/two/three/four/__init__.py
./one/two/three/four/e.py
./one/two/u.py
And you have
test.py
from one.two.t...
I'm relatively new to Django and I'm trying to build up my toolbox for future projects. In my last project, when a built-in template tag didn't do quite what I needed, I would make a mangled mess of the template to shoe-horn in the feature. I later would find a template tag that would have saved me time and ugly code.
So what are some...
In my application I run subprocesses under several different user accounts. I need to be able to read some of the information written to the registry by these subprocesses. Each one is writing to HKEY_CURRENT_USER, and I know the user account name that they are running under.
In Python, how can I read values from HKEY_CURRENT_USER for a...
def retCursor():
host = "localhost"
user = "disappearedng"
db = "gupan_crawling3"
conn = MySQLdb.connect( host=host, user=user, passwd=passwd, db=db)
cursor = conn.cursor()
return cursor
singleCur = retCursor()
def checkTemplateBuilt(netlocH):
"""Used by crawler specifically, this check directly whether tem...
Today I tried using pyPdf 1.12 in a script I was writing that targets Python 2.6. When running my script, and even importing pyPdf, I get complaints about deprecated functionality (md5->hashsum, sets). I'd like to contribute a patch to make this work cleanly in 2.6, but I imagine the author does not want to break compatibility for older ...
I'm using python's base64 module and I get a string that can be encoded or not encoded. I would like to do something like:
if isEncoded(s):
output = base64.decodestring(s)
else:
output = s
ideas?
...
hi,
i need to transfer large files across network and need to create checksum for them on hourly basis. so the speed for generating checksum is critical for me.
somehow i can't make zlib.crc32 and zlib.adler32 working with files larger than 4GB on Windows XP Pro 64bit machine. i suspect i've hit the 32bit limitation here? using hashlib...
According to the documentation on python's getopt (I think) the options fields should behave as the getopt() function. However I can't seem to enable optional parameters to my code:
#!/usr/bin/python
import sys,getopt
if __name__ == "__main__":
try:
opts, args = getopt.gnu_getopt(sys.argv[1:], "v::", ["verbose="])
excep...
I'm looking for a good, high-level python ftp client/server library. I'm working on a project that has "evolved" a small http/ftp library on top of ftplib/urllib/urllib2 from what was originally one function, and almost none of it was designed to be built upon. So now it's time to refactor kind of seriously, and I'd like to just switch t...
I have a file with a format similar to this:
a,3,4,2,1
3,2,1,a,2
I want to read the file and create an array of lists
in a way that:
array[0] = ['a','3','4','2','1']
array[1] = ['3','2','1','a','2']
How can I do that?
So far I am stuck with:
f = open('./urls-eu.csv', 'r')
for line in f:
arr = line.split(',')
print arr
But ...
The webbrowser library provides a convenient way to launch a URL with a browser window through the webbrowser.open() method. Numerous browser types are available, but there does not appear to be an explicit way to launch Internet Explorer when running python on windows.
WindowsDefault only works if Internet Explorer is set as the defaul...
I have a web service with Django Framework.
My friend's project is a WIN32 program and also a MS-sql server.
The Win32 program currently has a login system that talks to a MS-sql for authentication.
However, we would like to INTEGRATE this login system as one.
Please answer the 2 things:
I want scrap the MS-SQL to use only the Djang...
After updateing to mac osx 10.6 I had to switch back to python 2.5 in order to make virtual env work. But still I can not start my turbogears project. Paster is giving this :
Traceback (most recent call last):
File ".../tg2env/bin/paster", line 5, in <module>
from pkg_resources import load_entry_point
File ".../tg2env/lib/python...
I'm having issues with using ctypes. I'm trying to get the following project running on Vista.
http://sourceforge.net/projects/fractalfrost/
I've used the project before on Vista and had no problems. I don't see any think changed in svn that cause this I'm thinking it's something local to this machine. In fact I'm not able to load d...
Most likely it's a dumb question for those who knows the answer, but I'm a beginner, and here it goes:
I have a Python script which I run in a command-line with some parameter, and it prints me some results. Let's say results are some HTML code.
I never done any Python programming for web, and couldn't figure it out... I need to have a...
I have a Debian system currently running with python 2.5.4. I got virtualenv properly installed, everything is working fine. Is there a possibility that I can use a virtualenv with a different version of Python?
I compiled Python 2.6.2 and would like to use it with some virtualenv. Is it enough to overwrite the binary file? Or do I have...