python

QListWidget on freemantle

Hi, I have a problem with QListWidget on freemantle (maemo, n900). I want to use two QListWidget on same window and allow the user to pick on number in each window. When the user use the second QListWidget, the "blue" color on it disparear. How to change the color of a item selected in QListWidget which is not active ? ...

How to pass data from Google App Engine(Python) to Flex 4 application

I am using python and webapp framework in app engine for backend and flex 4 for front end. I would like to pass a string form backend to front end, so i write the following code in the main.py: class MainPage(webapp.RequestHandler): def get(self): userVO = "test" template_values = { 'url': self.request.uri, 'userVO': userV...

python twisted stdio multiple connections to a server with a command prompt for interaction

Hi, I have written a simple twisted application that connects to a server that listens on 1 or more ports. The twisted app connects to this server and usually connects to a few of the open ports at a time. This server is a serial logger that connects to serial devices and provides the serial line information through a raw TCP Socket an...

python string interpolation

What could generate the following behavior ? >>> print str(msg) my message >>> print unicode(msg) my message But: >>> print '%s' % msg another message More info: my msg object is inherited from unicode. the methods __str__/__unicode__/__repr__ methods were overridden to return the string 'my message'. the msg object was initiali...

Segmentation fault when importing pylab in a python script

I have installed Ubuntu 8.10. I am using python 2.6.4. I have installed the following packages networkx 1.0rc1 matplotlib 0.99.1.2 scipy 0.7.1 numpy 1.3 when I write the following statement in my code import pylab Also this statement gives a segmentation fault import matplotlib.pyplot as plt I receive a segmentation fault. What ...

Python ( or general programming ). Why use <> instead of != and are there risks?

I think if I understand correctly, a <> b is the exact same thing functionally as a != b, and in Python not a == b, but is there reason to use <> over the other versions? I know a common mistake for Python newcomers is to think that not a is b is the same as a != b or not a == b. Do similar misconceptions occur with <>, or is it exactl...

Window Icon of Exe in PyQt4

I have a small program in PyQt4 and I want to compile the program into an Exe. I am using py2exe to do that. I can successfully set icon in the windows title bar using the following code, but when i compile it into exe the icon is lost and i see the default windows application. here is my program: import sys from PyQt4 import QtGui cl...

Python Virtualbox API

http://enomalism.com/api/pyvb/ here we have def _init_(self,**kw): what parameter(s) should be passed when we create an instance for pyvb.vm.vbVM ??? ...

Scheduling Python Programs

How would you go about a having a function check something every ten minutes? I would like to check a directory for new files every ten minutes. I know python has a time library but can it be used for this? ...

Different 404 pages depending on the application in Django

We are developing a project with several applications using Django. It shares the database, but it has several applications targeting different very different users. Roughly, administrators and final users. The UI of each application is very different. I need to create a 404 error page, but seems that I can only create one for all the p...

Does PIL create artifacting on the bottom edge of the image when you thumbnail() then crop()? If so, what is your workaround ?

When I call PIL to thumbnail() an image, and then crop(), I get artifacting on the last row of pixels -- they're either mostly black with specks of intense color, or what seems to be a not-resized area of the image ( ie, that line of pixels is at the original resolution and did not scale down with the rest ) This does not seem to happen...

web2py, OAuth and LinkedIn

Hi everyone, i am new to Python and Web2py and i am developing an app that will use the LinkedIn api I use this library http://code.google.com/p/python-linkedin/ (it includes OAuth). My problem is very strange and that s why i am writing to the list. When i try to connect to LinkedIn from the web2py console i get a request Token. When i...

How to improve performance when interpolating on 3d data with SciPy

Hello there, I have 3d-data representing the atmosphere. Now I want to interpolate this data to a common Z coordinate (what I mean by that should be clear from the function's doctring). The following code works fine, but I was wondering if there were a way to improve the performance ... def interpLevel(grid,value,data,interp='linear'):...

Can the Django dev server correctly serve SVG?

I am trying to serve a svg map using: <object data="map.svg" type="image/svg+xml" width="400" height="300"> <embed src="map.svg" type="image/svg+xml" width="400" height="300" /> </object> In Firefox this leads to a plugin prompt. If I rename map.svg to map.xml it shows the image correctly. I assume this is because the Django's dev...

Controlling VirtualBox from commandline with python

We are using python virtualbox API for controlling the virtualbox. For that we are using the "pyvb" package(as given in python API documentation). al=pyvb.vb.VB() m=pyvb.vm.vbVM() al.startVM(m) we have executed using the python interpreter. No error is shown but the virtualbox doesnt start. Could you please tell us what could be wrong...

Programming language decision for C++ legacy project workflow

I have quite a lot of C++ legacy code modules from my colleagues, each doing different jobs. Unfortunately they are poorly written and yes, all GNU C++ code running under Linux. I want to write a controller program to make singular C++ module a workflow for a very urgent demo. Also I need to write a front-end web-app allowing clients s...

regex for state abbreviations (python)

I am trying to create a regex that matches a US state abbreviations in a string using python. The abbreviation can be in the format: CA Ca The string could be: Boulder, CO 80303 Boulder, Co Boulder CO ... Here is what I have, which obviously doesn't work that well. I'm not very good with regular expressions and google didn't tur...

Python: How to Access Linux Paths

Using Python, how does one parse/access files with Linux-specific features, like "~/.mozilla/firefox/*.default"? I've tried this, but it doesn't work. Thanks ...

Python: default value for a function

I am noticing the following: class c: def __init__(self, data=[]): self._data=data a=c() b=c() a._data.append(1) print b._data [1] Is this the correct behavior? ...

Conversion from imperative to functional programming [Python to Standard ML]

I have a function specification that states it that should evaluate a polynomial function of one variable. The coefficient of the function is given as a list. It also accepts the value of the variable as a real. For example: eval(2, [4, 3, 2, 1]) = 26 (1*x^3 + 2*x^2 + 3*x^1 + 4*x^0, where x = 2) Here's the function in python, but I'...