python

Google App Engine to Twisted

I was about to migrate the GAE-OpenSocial project to Twisted Matrix and Nevow. I am very new to Nevow templating and couldn't find good documentation other than given in Divmod's Nevow Project page. Is there any books relating to Nevow? I am having trouble serving static files in Nevow. For app engine its easy to define static files in a...

Can stuck Python threads hinder other threads if there are no shared resources?

I am considering utilizing Python to call various dlls that will perform things like accessing the LAN (on Windows) or making HTTP requests. These dlls might be poorly written and get stuck. My first question is, whether isolating these dll calls in Python threads will guarantee that the main Python thread will not get stuck? My second q...

Should i learn PHP (this is not vague..)

I have been into Python i know a bit. But what i really want is a good balance with web development and actual programs. For that i'll have to learn more than one language for sure. When i look at some companies (Google ) i see that Python has the power i thought it would have in web. But i would have to write the server myself. PHP has ...

Is python's shutil.move() atomic on linux ?

Hi, I am wondering whether python's shutil.move is atomic on linux ? Is the behavior different if the source and destination files are on two different partitions or is it same as when they are present on the same partition ? I am more concerned to know whether the shutil.move is atomic if the source and destination files are on the sa...

[matplotlib] customize ticks for AxesImage?

Hi, I have created an image plot with ax = imshow(). ax is an AxesImage object, but I can't seem to find the function or attribute I need to acess to customize the tick labels. The ordinary pyplots seem to have set_ticks and set_ticklabels methods, but these do not appear to be available for the AxesImage class. Any ideas? Thanks ~ ...

Python Twisted framework HTTP client

I want to write a simple SSL HTTP client in Python and have heard about the Twisted framework. I need to be able to authenticate with a REST service - so I was thinking I'd just POST a user name and password to the target server. Assuming authentication is successful, the client will receive a cookie. Will an HTTP client built on Twist...

Recognizing notes within recorded sound - Part 2 - Python

Hi folks, this is a continuation of this question here. This is the code I used in order to get the samples: spf = wave.open(speech,'r') sound_info = spf.readframes(-1) sound_info = fromstring(sound_info, 'Int16') The length of sound_info is 194560, which is 4.4 times the sample rate of 44100. The length of the sound file is 2.2 s...

Python: Setting sys.stdout to a wx.TextCtrl with Process/Thread leads to crashes

I've got a wx-gui that's piping stdout/stderr to two different text-controls. In the program I'm creating a process to run some data-crunching code, and I have a thread that joins the process and changes the global state when the process is finished. import multiprocessing as mp from threading import Thread t = Thread(target=self.joi...

What is the Java equivalent of Python's subprocess.Popen()?

import subprocess import os prefix = os.path.expanduser("~/.bin/kb/") p = subprocess.Popen([(prefix + "koreball"),(prefix + "/data"),'3']) ...

GtkExpander style widget in wxWidgets?

I'm looking for a widget along the lines of GtkExpander, but for wxWidgets. Can't seem to find anything obvious in the documentation. Custom widgets (non-GPL) from somewhere else would be fine, but they need to work on Windows (i.e. without GTK). Practically (if it makes any difference) this is primarily for wxPython, on Windows and hop...

PyQt ListView with groups

How can i create connection groups inside a QListView with PyQt. The group name should not be selectable. Example: http://www.shrani.si/f/T/bB/gSpSsYt/connectionlist.jpg :) ...

Sentence Splitter testing file.

Hi all, I am looking for a testing file for my Sentence Splitter Application, and i hope the file can cover as many cases as possible. Thanks! ...

Color handling in Python

For my clustering gui, I am currently using random colors for the clusters, since I won't know before hand how many clusters I will end up with. In python, this looks like: import random def randomColor(): return (random.random(),random.random(),random.random()) However, when I update things, the colors change. So what I would fa...

Memory error (MemoryError) when creating a boolean NumPy array (Python).

I'm using NumPy with Python 2.6.2. I'm trying to create a small (length 3), simple boolean array. The following gives me a MemoryError, which I think it ought not to. import numpy as np cond = np.fromiter((x in [2] for x in [0, 1, 2]), dtype = np.bool) The error it gives me is: MemoryError: cannot allocate array memory However, the ...

Which exception App Engine raises when a task nears the 30 second limit?

From Task Queue Python API Overview: If your task's execution nears the 30 second limit, App Engine will raise an exception which you may catch and then quickly save your work or log process. Which exception is that? ...

Python installation

Hello, i have a machine with two users accounts. i installed python in the first account without any problem but when am gone to install into the second account it cause the following error checking for C compiler default output file name... configure: error: C compiler cannot create executables caused when execute the following com...

What is a convenient way to store and retrieve boolean values in a CSV file

If I store a boolean value using the CSV module it gets converted to the strings 'True' or 'False' by the str() function. However when I load those values, a string of 'False' evaluates to being True because it's a non-empty string. I can work around it by 'manualy' checking the string at read time with an IF statement to see what the s...

Error while working with excel using python

while my script is updating one excel same time if i am going to do any other work manually with another excel error occurs i am using dispatch from win32com.client import Dispatch excel = Dispatch('Excel.Application') excel.Visible = True file_name="file_name.xls" workbook = excel.Workbooks.Open(file_name) workBook ...

Parsing twitter media in Python

Hello, can anyone tell me, is there any kind of python library, that parses a tweet (text data), and takes out links to popular media sharing services, like, twitpic, tweetphoto, and so on. I know, it's pretty easy to do it myself, but I think that existing tools might know more services, and maybe have API to access those services as w...

Django. You don't have permission to edit anything.

I created a little app a while ago. I created admin.py and used admin.site.register(MenuEntry) to add the class to admin console. It showed the items of that class just fine. Then I began working on another app and created everything as before. But now it says: You don't have permission to edit anything. I compared files from that and f...