python

How to get publisher.authors when you have book.publisher and book.author?

Fresh from the Djangobook tutorial using the Books app example, you have Book related to Author through a many-to-many relationship and Book related to Publisher. You can get a set of books associated with a publisher with p.book_set.all(), but what do you need to do to get a set of authors associated with a publisher (through the books ...

Check to see if python script is running

I have a python daemon running as a part of my web app/ How can I quickly check (using python) if my daemon is running and, if not, launch it? I want to do it that way to fix any crashes of the daemon, and so the script does not have to be run manually, it will automatically run as soon as it is called and then stay running. How can i ...

finding substrings in python

hi, Can you please help me to get the substrings between two characters at each occurrence For example to get all the substrings between "Q" and "E" in the given example sequence in all occurrences: ex: QUWESEADFQDFSAEDFS and to find the substring with minimum length. ...

How do i interface with the MSN Protocol using Python?

I am trying to connect to the MSN network using Python.. I've done some searching and it seems like http://blitiri.com.ar/p/msnlib/ and http://msnp.sourceforge.net/ are the available libraries. However both seem very old and is there any other up to date library that i can use? Dupplicate of : http://stackoverflow.com/questions/490929/m...

C++ for Python Programmers: Slides and Resources

I have been teaching some bright high school kids Python for 3 months now (for most of them this was their first experience with programming). I've decided to take the best of the group of give them a quick (120 minute) introduction to C++. They're hard-working enough to take what we give them and learn things further on their own. Are ...

Problem running twisted.words example using msn protocol

I am currently trying to use the Twisted library specifically twisted words to try and interat with MSN. However when i run the sample script provided by twisted , i get an error. Specifically the error is found here http://i42.tinypic.com/wl945w.jpg . The script can be found over here http://twistedmatrix.com/projects/words/documentatio...

How do I reverse the direction that my rectangles travel?

I am very new at programming as it was only just introduced into my school as a subject and I need some help. I have been given the task to have an animation of three balls (rectangle images) bouncing around the screen and off each other. I have the three balls and the bouncing of the walls all down good, but I don't know how to have the...

How can I import the sqlite3 module into Python 2.4?

The sqlite3 module is included in Python version 2.5+. However, I am stuck with version 2.4. I uploaded the sqlite3 module files, added the directory to sys.path, but I get the following error when I try to import it: Traceback (most recent call last): File "<stdin>", line 1, in ? File "sqlite3/__init__.py", line 23, in ? from d...

How do I watch a serial port with QSocketNotifier (linux)?

Could someone give me an example on how to setup QSocketNotifier to fire an event if something comes on /dev/ttyS0 ? (preferably in python/pyqt4) ...

Converting an ImageMagick FX operator to pure Python code with PIL

I'm trying to port some image processing functionality from an Image Magick command (using the Fx Special Effects Image Operator) to Python using PIL. My issue is that I'm not entirely understanding what this fx operator is doing: convert input.png gradient.png -fx "v.p{0,u*v.h}" output.png From a high level, this command takes the c...

Handling Authorization in web frameworks

I want to write a simple web framework myself using WSGI, Python. I am in study to understand the authorization system. The system needs to be more modular and abstract enough to add new system into the project as a plug-in. User may use DB or distributed key/value pair, bigtable, etc to store their information. Lets say, these sort o...

How to debug Google App Engine scripts with PyScripter

The situation is as follows: I have downloaded the Google App Engine SDK. I have written my "helloworld" app that runs locally in my computer. I have to use PyScripter as IDE. I can't use Eclipse, that would not be a valid solution to my problem. In PyScripter, I have set a "Run Configuration", so that an instance of the server run...

What is the easiest way to build Python26.zip for embedded distribution?

Hello, I am using Python as a plug-in scripting language for an existing C++ application. I am able to embed the python interpreter as stated in the Python documentation. Everything works successfully with the initialization and de-initialization of the interpreter. I am, however, having trouble loading modules because I have not been a...

What are some successful methods for deploying a Django application on the desktop?

I have a Django application that I would like to deploy to the desktop. I have read a little on this and see that one way is to use freeze. I have used this with varying success in the past for Python applications, but am not convinced it is the best approach for a Django application. My questions are: what are some successful methods ...

What is the best way to redirect email to a Python script?

I'd like to provide a functionality for users of my website to get assigned an email address upon registration (such as [email protected]) but I don't really think it is feasible to actually support all these emails account normally through a webmail program. I am also not sure if my webhost would be cool with it. What I'd ...

Why builtin functions instead of root class methods?

(I'm sure this is a FAQ, but also hard to google) Why does Python use abs(x) instead of x.abs? As far as I see everything abs() does besides calling x.__abs__ could just as well be implemented in object.abs() Is it historical, because there hasn't always been a root class? ...

Turning on debug output for python 3 urllib

In python 2, it was possible to get debug output from urllib by doing import httplib import urllib httplib.HTTPConnection.debuglevel = 1 response = urllib.urlopen('http://example.com').read() However, in python 3 it looks like this has been moved to http.client.HTTPConnection.set_debuglevel(level). However, I'm using urllib not http....

django on Google Appengine

I came across 2 different modules for porting django to appengine. http://code.google.com/p/app-engine-patch/ http://code.google.com/p/google-app-engine-django/ Both seem to be compatible with django 1.0, The featured download of the latter is in Aug 08, whereas the former is Feb 09. What are the relative merits. What if I dont use...

Locales and temperature/length conversion

Do locales contain information about preferred units for temperature, lengths, etc. on Unix/Linux? Is it possible to access these properties from Python? I checked out the "locales" module, but didn't find anything suitable. I'd like my application to automatically convert values into the most suitable unit. ...

cannot run appengine-admin on dev_server

I've decided to try out this project: http://code.google.com/p/appengine-admin/wiki/QuickStart For the sake of the experiment, I took the demo guest-book shipped with app-engine. The import park look like this: import cgi import datetime import wsgiref.handlers from google.appengine.ext import db from google.appengine.api import use...