python

python: interact with the session in cgi scripts

Can python cgi scripts write and read data to the session? If so how? Is there a high-level API or must I roll my own classes? ...

reading midi input

hi, is there a module to read midi input (live) with python? ...

Worker/Timeslot permutation/constraint filtering algorithm

Hope you can help me out with this guys. It's not help with work -- it's for a charity of very hard working volunteers, who could really use a less confusing/annoying timetable system than what they currently have. If anyone knows of a good third-party app which (certainly) automate this, that would almost as good. Just... please don'...

Python Clientform-can not get expexted result

I am trying to search through http://www.wegottickets.com/ with the keywords "Live music". But the returned result is still the main page, not the search result page including lots of live music information. Could anyone show me out what the problem is? from urllib2 import urlopen from ClientForm import ParseResponse response = urlopen...

When and how to use the builtin function property() in python

It appears to me that except for a little syntactic sugar, property() does nothing good. Sure, it's nice to be able to write a.b=2 instead of a.setB(2), but hiding the fact that a.b=2 isn't a simple assignment looks like a recipe for trouble, either because some unexpected result can happen, such as a.b=2 actually causes a.b to be 1. Or...

Implementing "Starts with" and "Ends with" queries with Google App Engine

Hi, Am wondering if anyone can provide some guidance on how I might implement a starts with or ends with query against a Datastore model using Python? In pseudo code, it would work something like... Query for all entities A where property P starts with X or Query for all entities B where property P ends with X Thanks, Matt ...

Problem to make an apache server run correctly under mod_python

Hello to all, We try to migrate our old server to a new one but we experienced some problems with mod_python. The problem is under this web page: http://auction.tinyerp.org/auction-in-europe.com/aie/ Here is our apache2 configuration: NameVirtualHost * <VirtualHost *> DocumentRoot /var/www/ <Directory /> Options FollowSymLin...

How do I ask for an authenticated url directly with python

I want to get to an authenticated page using urllib2. I'm hoping there's a hack to do it directly. something like: urllib2.urlopen('http://username:pwd@server/page') If not, how do I use authentication? ...

Getting input from MIDI devices live (Python)

I've got a trigger finger (MIDI tablet) and I want to be able to read its input live and make python execute actions depending on the pressed key. I need it for Windows, and preferably working with python 2.5 + Thanks ...

How do I know what's the realm and uri of a site

I want to use python's urllib2 with authentication and I need the realm and uri of a url. How do I get it? thanks ...

Fill form values in a web page via a Python script (not testing)

I need to fill form values on a target page then click a button via Python. I've looked at Selenium and Windmill, but these are testing frameworks - I'm not testing. I'm trying to log into a 3rd party website programatically, then download and parse a file we need to insert into our database. The problem with the testing frameworks is th...

webbrowser.get("firefox") on a Mac with Firefox "could not locate runnable browser"

I think what I need here is to know which magic command-line or OSA script program to run to start up a URL in an existing Firefox browser, if one is running, or to also start up Firefox if it isn't. On Mac. I'm testing a Python program (Crunchy Python) which sets up a web server then uses Firefox for the front end. It starts the web ap...

Cherrypy server unavailable from anything but localhost.

I am having an issue with cherrypy that looks solved, but doesn't work. I can only bind on localhost or 127.0.0.1. Windows XP Home and Mac OS X (linux untested), cherrypy 3.1.2, python 2.5.4. This is the end of my app: global_conf = { 'global': { 'server.environment= "production"' 'engine.autoreload_on :...

How to iterate over columns of an image?

I want to transform images like this to add an effect to pictures in django as described here. I decided to implement it as a process for the great django-imagekit/photologue My knowledge of PIL isn't very good, so my question is How to intend a column of pixels by a sinus-offset in PIL? any hints (code, lins, general thoughts) ar...

appengine remote api unable to login

When I go to appengine.google.com/a/mydomain.com i am able to login and see all my apps and administer them. However, when I try to use the remote_api the same username/password does not work. I'm using the interactive console code from http://code.google.com/appengine/articles/remote%5Fapi.html ...

sending a non-blocking HTTP POST request

Hi, I have a two websites in php and python. When a user sends a request to the server I need php/python to send an HTTP POST request to a remote server. I want to reply to the user immediately without waiting for a response from the remote server. Is it possible to continue running a php/python script after sending a response to the u...

Can one prevent Genshi from parsing HTML entities?

I have the following Python code using Genshi (simplified): with open(pathToHTMLFile, 'r') as f: template = MarkupTemplate(f.read()) finalPage = template.generate().render('html', doctype = 'html') The source HTML file contains entities such as &copy;, &trade; and &reg;. Genshi replaces these with their UTF-8 character, which cau...

How to dereference a memory location from python ctypes?

I want to replicate the following c code in python ctypes: main() { long *ptr = (long *)0x7fff96000000; printf("%lx",*ptr); } I can figure out how to call this memory location as a function pointer but not just do a normal dereference: from ctypes import * """ >>> fptr = CFUNCTYPE(None, None) Traceback (most recent call last): ...

Efficient way to find the largest key in a dictionary with non-zero value

Hi, I'm new Python and trying to implement code in a more Pythonic and efficient fashion. Given a dictionary with numeric keys and values, what is the best way to find the largest key with a non-zero value? Thanks ...

Python AppEngine And HTML

Hello, I have a simple Hello World application in Python that i'm using with AppEngine, but i want to insert this in a HTML file, like this: I have a file called test.html and on it i have this snippet: <center><img src="test.png></center> // Here comes the Python App // I want to put the output of the Python application in this spac...