python

Formatting SQL query output in Python/SQLite 3

I use a simple SQL query in Python to grab records from a SQLite 3 database: cursor.execute ("SELECT due, task FROM tasks WHERE due <> '' ORDER BY due ASC") rows = cursor.fetchall() for row in rows: print '\n%s %s' % (row[0], row[1]) The due field in the database is set to DATE type, so the query re...

Improving performance of cgi

I have 5 python cgi pages. I can navigate from one page to another. All pages get their data from the same database table just that they use different queries. The problem is that the application as a whole is slow. Though they connect to the same database, each page creates a new handle every time I visit it and handles are not shared ...

Python recursion

What's the maximum level of recursion and how do I change it in Python? ...

functions in python query

def directionToVector(direction, speed = 1.0): dx, dy = Actions._directions[direction] return (dx * speed, dy * speed) def getCostOfActions(self, actions): """ Returns the cost of a particular sequence of actions. If those actions include an illegal move, return 999999. This is implemented for you. """ if ...

Web-ifing a python command line script ?

Hello everybody, This is my first questions here, so I hope it will be done correctly ;) I've been assigned the task to give a web interface to some "home made" python script. This script is used to check some web sites/applications availability, via curl commands. A very important aspect of this script is that it gives its results in ...

nulls object in Python?

How do I refer to the null object in Python? ...

Good apps I could use to store a page locally?

Hi folks, I really need to find a reliable way in order to store a web page locally, with all it's dependencies e.g. html, css stylesheets, javascript, etc... A python library would be awesome, a CLI would be great too. Also would this type of app/library have a standardized name? Any suggestions guys? =) ...

lists in python, with references

How do I copy the contents of a list and not just a reference to the list in Python? ...

python time problem

Hello, I am using the exif.py library. After calling tags=exif.process_file(...) i want to retrieve the time the image was captured. so i continue with t =tags['Image DateTime'] if tags.has_key('Image DateTime') else time.time() now i want to store t in django's database. For that t must be in the form 2010-07-20 14:37:12 but app...

Audio waveform visualisation in Python/Django

I've looked around Stack Overflow for an answer to this, but nowhere seems to give the correct answer or direction... My project will allow a user to upload a WAV, which ultimately will be converted to a low quality MP3 using FFmpeg on the server and it'll all be stored and served on Amazon S3. The next obstacle is working out how to ex...

Python Beautiful soup tag for table td

Python Beautiful soup tag for table td <td class="result" valign="top" colspan="3"> At the moment, the following does not work: for header in soup('table', 'td .result'): Getting error: HTMLParser.HTMLParseError: malformed start tag ...

No icons in pyQt exec application built with bbfreeze

Hi, The story is: I have working pyQt4 GUI application. After building *.qrc and *.ui files I run it from commandline: python myapp.py And I see my astonishing ;) icons. When I 'compile' it with bbfreeze there are no icons. I know that currently bbfreeze doesn't support icons, but I thought that when pyqt resources are compiled an...

Read from a log file as it's being written using python

Hi, I'm trying to find a nice way to read a log file in real time using python. I'd like to process lines from a log file one at a time as it is written. Somehow I need to keep trying to read the file until it is created and then continue to process lines until I terminate the process. Is there an appropriate way to do this? Thanks. ...

Blender, UV Layer, Image and Python

Hi, I'm trying to access UV Layer in Blender from Python and basically API returns UV Layer only as a string. Thing is I want to assign new Image object to current UV Layer ( I use TexFace on the side of material ) and then just bake lighting. All meshes are currently unwrapped, the only thing which is missing is an Image and I have no ...

urllib2 and json

Hi, can anyone point out a tutorial that shows me how to do a POST request using urllib2 with the data being in JSON format? ...

Method logging in Python

I'd like something equivalent to calling method: $METHOD_NAME args: $ARGS output: $OUTPUT to be automatically logged to a file (via the logging module, possibly) for every (user-defined) method call. The best solution I can come up with is to write a decorator that will do this, and then add it to every function. Is ...

Foursquare Oauth with Python

I'm trying to figure out Foursquare's OAuth so I can have a user sign into my app. So far I found this tutorial: http://pkarl.com/articles/connect-foursquare-api-oauth-python/ Unfortunately, it doesn't work. I got the same error message the commenters were getting. If anyone knows what the tutorial did wrong or knows another way of aut...

Memory not released by python cherrypy application on linux

I have a long running process that will fetch 100k rows from the db genrate a web page and then release all the small objets (list, tuples and dicts). On windows, after each request the memory is freed. Howerver, on linux, the memory of the server keeps growing. The following posts describes what the problem is and one possible solution...

python , how to find class object from child entity ?

my code is following in python. class A(object): b = B() def d(self): print "Hi" class B(): def C(self): self.__self__.d()#edit ::: i need to call d() method here. i know __self__ is wrong # do knowledge for B being variable inside object A needed ? i.e # passing parent object via init is needed as show...

BaseHTTPServer not recognizing CSS files

Hey there, I'm writing a pretty basic webserver (well, trying) and while it's now serving HTML fine, my CSS files don't seem to be recognized at all. I have Apache2 running on my machine as well, and when I copy my files to the docroot, the pages are served correctly. I've also checked permissions and they seems to be fine. Here's th...