python

How do I blink/control Macbook keyboard LEDs programmatically?

Hi, I've googled for this, but no results, so I ask you guys for help. Do you know how I can switch on/off (blink) Macbook keyboard leds (capslock,numlock) under Mac OSX (preferably Tiger). I would like to add this feature as notifications (eg. new message received on Adium, new mail received). I would prefer applescript, python, but...

Python - Py2exe can't build .exe using the 'email' module

py2exe does not work with the standard email module Hello. I am trying to use py2exe for converting a script into an exe. The build process shows this: The following modules appear to be missing ['email.Encoders', 'email.Generator', 'email.Iterators', 'email.MIMEBase', 'email.MIMEMultipart', 'email.MIMEText', 'email.Utils', 'email.b...

What is the best way to run multiple subprocesses via fork()?

A python script need to spawn multiple sub-processes via fork(). All of those child processes should run simultaneously and the parent process should be waiting for all of them to finish. Having an ability to set some timeout on a "slow" child would be nice. The parent process goes on processing the rest of the script after all kids are...

How to output CDATA using ElementTree

I've discovered that cElementTree is about 30 times faster than xml.dom.minidom and I'm redoing my XML encoding decoding code. However, I need to output XML that contains CDATA sections and there doesn't seem to be a way to do that with ElementTree. Can it be done? ...

Is there a definitive book on Python?

There have been several questions here on SO about resources for learning Python (which have been most helpful,) but I was wondering if there was some consensus in the Python community about what the definitive reference book was once you knew the language? I'm hoping for something along the same lines as K&R's "The C Programming Langua...

django development IDE

I have done a little django development but it has all been in a text editor. I was curious what more advanced development tools others are using in their django development. I am used to using Visual Studio for development and really like the intellisense, code completion, and file organization it provides and would like to find somet...

How do I convert a file's format from Unicode to ASCII using Python?

I use a 3rd party tool that outputs a file in Unicode format. However, I prefer it to be in ASCII. The tool does not have settings to change the file format. What is the best way to convert the entire file format using Python? ...

writing optimization function

I'm trying to write a tennis reservation system and I got stucked with this problem. Let's say you have players with their prefs regarding court number, day and hour. Also every player is ranked so if there is day/hour slot and there are several players with preferences for this slot the one with top priority should be chosen. I'm thinki...

Python List vs. Array - when to use?

If you are creating a 1d array, you can implement it as a List, or else use the 'array' module in the STDLIB. I have always used Lists for 1d arrays. What is the reason or circumstance where I would want to use the array module instead? Is it for performance and memory optimization, or am I missing something obvious? ...

Writing a reliable, totally-ordered multicast system in Python

I have to write a reliable, totally-ordered multicast system from scratch in Python. I can't use any external libraries. I'm allowed to use a central sequencer. There seems to be two immediate approaches: write an efficient system, attaching a unique id to each multicasted message, having the sequencer multicast sequence numbers for ...

Building a full text search engine: where to start.

Hello. I want to write a web application using Google App Engine (so the reference language would be Python). My application needs a simple search engine, so the users would be able to find data specifying keywords. For example, if I have one table with those rows: 1 Office space 2 2001: A space odyssey 3 Brazil and the user qu...

Where can I find a good tutorial for py2exe?

Can somebody point me at a good tutorial for py2exe? I've read over the official tutorial but it is rather light on details, compared to all the options one can use when building an executable out of a python script. For the record, my python script uses Python 2.5.2, wxPython/wxWidgets 2.8 and MySQLdb 1.2.2; so if you have specific ti...

In Python, how do I find the index of an item given a list containing it?

For a list ["foo","bar","baz"] and a variable "bar", what's the cleanest way to get its index 1 in python? ...

Offline access to MoinMoin wiki using Google Gears

How to add offline access functionality to MoinMoin wiki? As a minimum, I would love to have browsing access to all pages on a server-based wiki (while being offline). Search and other things, which do not modify the content, are secondary. An added bonus would be if this solution allowed to update wiki content while offline and push i...

SQL Absolute value across columns

I have a table that looks something like this: word big expensive smart fast dog 9 -10 -20 4 professor 2 4 40 -7 ferrari 7 50 0 48 alaska 10 0 1 0 gnat -3 0 0 0 The + and - values are associated with the...

Alert boxes in Python?

Is it possible to produce an alert similar to JavaScript's alert("message") in python, with an application running as a daemon. This will be run in Windows, Most likely XP but 2000 and Vista are also very real possibilities. Update: This is intended to run in the background and alert the user when certain conditions are met, I figure t...

Testing socket connection in Python

This question will expand on: http://stackoverflow.com/questions/68774/best-way-to-open-a-socket-in-python When opening a socket how can I test to see if it has been established, and that it did not timeout, or generally fail. Edit: I tried this: try: s.connect((address, '80')) except: alert('failed' + address, 'down') but th...

Keeping filters in Django Admin

What I would like to achive is: I go to admin site, apply some filters to the list of objects I click and object edit, edit, edit, hit 'Save' Site takes me to the list of objects... unfiltered. I'd like to have the filter from step 1 remembered and applied. Is there an easy way to do it? ...

What is a good PDF report generator tool for python?

What is a good tool for PDF report generation in Python? I've checked out ReportLab, but it seems to be awfully low-level for what I want to do. My current hunch is to call TeX on the command-line and let it produce the PDF, but if there is something that is easier to work with (and looks professional - We'll send this to customers) I'd ...

Accessing python egg's own metadata

I've produced a python egg using setuptools and would like to access it's metadata at runtime. I currently got working this: import pkg_resources dist = pkg_resources.get_distribution("my_project") print(dist.version) but this would probably work incorrectly if I had multiple versions of the same egg installed. And if I have both inst...