python

Recognising tone of the audio

Hi, I have a guitar and I need my pc to be able to tell what note is being played, recognizing the tone. Is it possible to do it in python, also is it possible with pygame? Being able of doing it in pygame would be very helpful. ...

Parsing a hex formated DEC 32 bit single precision floating point value in python

I'm having problems parsing a hex formatted DEC 32bit single precision floating point value in python, the value I'm parsing is represented as D44393DB in hex. The original floating point value is ~108, read from a display of the sending unit. The format is specified as: 1bit sign + 8bit exponent + 23bit mantissa. Byte 2 contains the si...

Fabric error No handlers could be found for logger "paramiko.transport"

I'm not sure why I'm getting this error that's terminating my connection. I updated paramiko-1.7.6 from 1.7.5 via easy_install. I'm trying to setup Fabric to upload my Django app to my server. The error seems to be happening when I attempt to make a backup of the existing app directory: def backup_current_install(): now = datetime.da...

Artificial Inteligence library in python

I was wondering if there are any python AI libraries similar to aima-python but for a more recent version of python... and how they are in comparison to aima-python. I was particularly interested in search algorithms such as hill-climbing, simulated annealing, tabu search and genetic algorithms. edit: made the question more clear. ...

Python CGI script IOError Broken Pipe

I have an old Python based web form that I am updating to use a GPG for encyption instead of a no longer supported python package. When call the script via the command line it works just fine, but via the web brower and CGI there is a error: IOError: [Errno 32] Broken pipe. This error occurs if I use the gnupg package or if I try to talk...

Launching default application for given type of file, OS X

I'm writing a python script that generates html file. Every time I run this script I'd like at the end to open default system browser for this file. It's all in OS X environment. What python code can launch Safari/Firefox/whatever is system default html viewer and open given file? subprocess.call doesn't seem to do the trick. ...

Overcoming Python's limitations regarding instance methods

It seems that Python has some limitations regarding instance methods. Instance methods can't be copied. Instance methods can't be pickled. This is problematic for me, because I work on a very object-oriented project in which I reference instance methods, and there's use of both deepcopying and pickling. The pickling thing is done mos...

Python Remove last 3 characters of a string

I'm trying to remove the last 3 characters from a string in python, I don't know what these characters are so I can't use rstrip, I also need to remove any white space and convert to upper-case an example would be: foo = "Bs12 3ab" foo.replace(" ", "").rstrip(foo[-3:]).upper() This works and gives me BS12 which is what I want, howeve...

basic python module design question

I have: lib/ lib/__init__.py lib/game.py In __init__.py I'd like to define a variable that can be accessed by any class inside lib, like so: BASE = 'http://www.whatever.com' And then inside game.py, acces it inside in the Game class: class Game: def __init__(self, game_id): self.game_id = game_id url = '%syear_%s/month_%...

python : list index out of range error

I have written a simple python program l=[1,2,3,0,0,1] for i in range(0,len(l)): if l[i]==0: l.pop(i) This gives me error 'list index out of range' on line if l[i]==0: After debugging I could figure out that i is getting incremented and list is getting reduced. However, I have loop termination condition i < len(l)....

Download file using partial download (HTTP)

Is there a way to download huge and still growing file using partial-download feature ? It seems that code like this import urllib urllib.urlretrieve ("http://www.example.com/huge-growing-file", "huge-growing-file") downloads file from scratch every time it executed. I'd like to fetch just the newly written data and download from scra...

Python: print doesn't work, script hangs endlessly...

Using Python 2.6, I wrote a script in Windows XP. The script does the following: Input: Domain name (ie: amazon.com) The script queries DNS via the dnspython module and returns any A record IP Addresses. The output is in a special format needed for a specific application which utilizes this data. This works fine in Windows, but when ...

importing cx_Oracle and kinterbasdb returns error

Greetings, everybody. I'm trying to import the following libraries in python: cx_Oracle and kinterbasdb. But, when I try, I get a very similar message error. *for cx_Oracle: Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: Não foi possível encontrar o procedimento especificado. (translation: It wa...

Numpy - show decimal values in array results

hello, how do I calculate that an array of python numpy or me of all the calculate decimals and not skip like. >> A = numpy.array ([[1,2,3], [4,5,6], [7,8,9]]). >> C = numpy.array ([[7,8,9], [1,2,3], [4,5,6]]). >> A / C array ([[0, 0, 0], [4, 2, 2], [1, 1, 1]]) but in the first vector would not have to be given to abs...

Django Admin "Edit Selection" Action?

I'd like to write a django-admin action (for use when the user selects zero or more rows) that will allow them to edit the selected items as a group. I only need to edit one of the items in the model (the "room") at a time, but I don't want to have to go through all 480 of my objects and manually edit them one-by-one. Is there a way to ...

replace values in an array

hello all, as a replacement value for another within an operation with arrays, or how to search within an array and replace a value by another for example: array ([[NaN, 1., 1., 1., 1., 1., 1.] [1., NaN, 1., 1., 1., 1., 1.] [1., 1., NaN, 1., 1., 1., 1.] [1., 1., 1., NaN, 1., 1., 1.] [1., 1., 1., 1., NaN, 1.,...

Selenium - Pop Up window

Hi , I am testing the Router UI using selenium. I am using cisco routers. I am pinging a website and the router opens a pop up window showing the Ping statistics. The selenium ide is recording the popup window as " Ping table " but when i am running it the ide shows an error. I want to verify and validate the data in the pop up window ...

Can I put Hudson Plots on the project page?

I've got Hudson up and running, building Django and Python projects I'm working on. I've found and am using the [Plot plugin][2] to graph Pylint scores, by extracting them with Awk to create a pylint.properties file. So far everything is working great, but I'd like to have the Pylint score appear on the project page. Right now you have...

Most pythonic way of ignoring output

I've got a class which uses the context management protocol to have a silent stderr stream for a while (mainly used for py2exe deployments, where the app writing anything to stderr causes ugly dialogs when the app is closed, and I'm doing something that I know will have some stderr output) import sys import os from contextlib import con...

How to intercept WM_DELETE_WINDOW on OSX using Tkinter

I'm trying to keep a Toplevel window from being closed in OSX by intercepting window manager WM_DELETE_WINDOW event. #!/usr/bin/env python from Tkinter import * def speak(): print "woof" root = Tk() root.title("root") win = Toplevel() win.title("win") win.protocol('WM_DELETE_WINDOW', speak) root.mainloop() When I run this I g...