python

Libraries for manipulating multivariate polynomials

Hi. I need to write some code that deals with generating and manipulating multivariable polynomials. I'll outline my task with a simplified example. Lets say I am given three expressions: 2x^2, 3y + 1, and 1z. I then need to multiply these together which would give me 6x^2yz + 2x^2z. Then I would like to find the partial derivatives of...

Using NumPy and Cpython with Jython

I must use a commercial Java library, and would like to do it from Python. Jython is robust and I am fine with it being a few dot releases behind. However, I would like to use NumPy as well, which obviously does not work with Jython. Options like CPype and Java numeric libraries are unappealing. The former is essentially dead. The latter...

How do a debug an exception on python shutdown

When my process ends, I get output to stderr that looks like: Exception exceptions.TypeError: "'NoneType' object is not callable" in <function <lambda> at 0x5507d70> ignored My understanding is that this is caused by exceptions being generated during garbage collection (del() ?) or the weakref callback which I know is being used in ...

Most minimal Apache2 configuration for a python script that wgets, combines with local files and provides zip?

I have a PHP site setup on my server that also has mod_wsgi + Python 2.5 on it. Occasionally I'm going to be asked to provide a zip of the entire site, and I'd like to use Python instead of PHP to do this. What's the most minimal configuration I could make so that my python script is web accessible in order such that it can wget and gr...

Are the two codes equivalent to each other?

i know ive asked similar questions like this before, but: Is this pseudocode here the same as my code? upper case variables are the variables in the pseudocode with " ' " and the values with conditions are all in lists, such as: all "s" conditions are in list "s", and " s' " conditions in list "S" for i in xrange(t): a = h0; b = h1;...

How to compile Mercurial and move it to another computer.

I have been trying to install Mercurial on a GoDaddy deluxe server which I have ssh access to. It fails because the server does not have GCC installed and I do not wish to attempt to install it. GoDaddy support said I need to compile Mercurial locally and move it to their server. Could anybody refer me to some resources on how to compil...

Python access to first element in dictionary

If dict is not empty, the way I use to access 1st element in dict is: dict[dict.keys()[0]] Is there any better way to do this? Thanks. ...

Time to decimal time in Python

Which Python datetime or time method should I use to convert time in HH:MM:SS to decimal time in seconds? The times represent durations of time (most are less than a minute) and are not connected to a date. ...

Method for guessing type of data represented currently represented as strings in python

I'm currently parsing CSV tables and need to discover the "data types" of the columns. I don't know the exact format of the values. Obviously, everything that the CSV parser outputs is a string. The data types I am currently interested in are: integer floating point date boolean string My current thoughts are to test a sample of ...

Root mean square difference between two images using Python and PIL

I need to have a function like the one found here: http://effbot.org/zone/pil-comparing-images.htm that calculates the root mean square difference between two images. The code looks like this: import ImageChops import math, operator def rmsdiff(im1, im2): "Calculate the root-mean-square difference between two images" h = Image...

Most efficient way to sort/categories objects in list based on object attribute

I have an unsorted list of objects that each have a end_date attribute. The list just looks like [obj1, obj2, obj3, <...>] in no specific order. I want to end up with a list that looks like this: [["Saturday, May 5", [obj3, obj5]], ["Monday, May 7", [obj1, obj8, obj9]] ... etc ] Basically just a list of lists, where the "key" is t...

Input from 20+ microphones

I've been asked (if it's possible) to write a program monitoring the input of at least 20 microphones, on a single computer. Currently I'm prototyping in python (2.6), on a Ubuntu system using Alsa. My attempts so far have created quite a few questions... Ubuntu is a requirement, Alsa isn't, and python is an ideal. For hardware, one s...

Implementing a special type of multiprocessing queue in Python

Imagine an inverted binary tree with nodes A, B, C, D, E, F on level 0. nodes G,H,I on level 1, node J on level 2, and node K on level 3. Level 1: G = func(A,B), H = func(C,D), I = func(E,F) Level 2: J = func(G,H) Level 3: K = func(J,I). Each pair of nodes on Level 0 must be processed in order, Each pair of nodes on Level 1 can be ...

how to read rss feed to gae-database .

any gae-lib to do this i think maybe jquery can do this too , yes ? thanks ...

How to discover current role in Python Fabric

Hi This is a very Fabric specific question, but more experienced python hackers might be able to answer this, even if they don't know Fabric. I am trying to specify different behaviour in a command depending on which role it is running for, i.e.: def restart(): if (SERVERTYPE == "APACHE"): sudo("apache2ctl graceful",pty=Tr...

ImportError: No module named Foundation

Hey all, I'm pretty new to python, so bear with me. I want to write a simple script using some components of PyObjC. I'm running on Mac OS 10.5, so from what I've read, it's included. However, opening up a simple python prompt and typing import Foundation gives me the error ImportError: No module named Foundation. For reference, my sy...

It's possible to make a program that shows FPS (frame per second) in Python?

I was wondering... It's possible to do it? A simple console command based program that shows how are your FPS, for your currently running game/program? ...

date library, capable of calculating things like "every third tuesday"?

I'd like to find a library or command that given input like "every third tuesday" will provide a list of dates such as (2010-06-15, 2010-07-20, 2010-08-17), etc. Something that can be called from python, unix command line, or a web api would be perfect. ...

Question on for loop syntax in python

I am new to python,can anybody please explain the following syntax, for i in [line.split('"') for line in open('a.txt')]: ...... ...... ...... ...

Changing the selected item colour in a gtk treeview using python

I have a dialog which contains a pygtk.treeview for listing tasks by priority. Each row has the background colour set based on that priority, so for example the highest priority has a light red background. The row selection color is not so easy to change. I can set it using treeview.modify_base(gtk.STATE_SELECTED, "#C4C4C4"), but no col...