python

Why do I get encoding error in python warnings.formatwarning on format string?

I get encoding error on this line: s = "%s:%s: %s: %s\n" % (filename, lineno, category.__name__, message) UnicodeEncodeError: 'ascii' codec can't encode character u'\xc4' in position 44: ordinal not in range(128) I tried to reproduce this error by passing all combinations of parameters to string format, but closest I got was "ascii ...

PyQt context menu

Hi guys, I'm adding a contextmenu to a QTableWidget dynamically: playlistContenxt = QAction("Add to %s" % (currentItem.text()), self.musicTable) playlistContenxt.setData(currentData) self.connect(playlistContenxt, SIGNAL("triggered()"), self.addToPlaylistAction) self.musicTable.addAction(playlistContenxt) currentItem.text() is a play...

Is an applet a proper solution for hardware detection and driver install?

Can I use applets to inform me which hardware is installed on client system (fingerprint reader)? And if it is installed, can it tell me its version, so that it can download the proper plugin from a site? So that after everything is OK, the user can use his fingerprint reader to authenticate himself? ...

Boo vs C# vs Python?

I was (yes, was) a Python (and before VB6) lover until tried to create GUI applications. It is very (very) difficult to create a GUI, and making executables (A hello world app was 2 MB). Then, I jumped to VB.NET, but collections looked hard, strange and foolish to me. Then, jumped to C#, but don't really know C# well now. I ordered a go...

Proxying imported schema but not SOAP requests with suds

I'm writing a SOAP client to talk to servers on our local network but our provider's WSDL references but doesn't import the SOAP encoding schema. We can fix this up with suds' ImportDoctor but doing so requires access to the internet to fetch the schema. Our internet access is via an HTTP proxy. If I set the $http_proxy environment varia...

How do I display images at different times on webpage

Hello, I'm supposed to display images at certain times of the day on the webpage, Please can anyone tell me how to go about it ...

How to fix encoding in Python Mechanize?

Hello, here is the sample code: from mechanize import Browser br = Browser() page = br.open('http://hunters.tclans.ru/news.php?readmore=2') br.form = br.forms().next() print br.form The problem is that server return incorrect encoding (windows-cp1251). How can I manually set the encoding of the current page in mechanize? Error: Tra...

Python: smarter way to calculate loan payments

How to calculate the monthly fee on a loan? Given is: a: an amount to loan. b: the loan period (number of months). c: the interest rate p.a. (interests is calculated and added every month, 1/12 of the interest is added. So if the interest is on 12%, 1% interest is added every month). d: the amount of money owed after the end of the pe...

Creating files on AppEngine

I'm trying to store some data in a binary file: import os, pickle o = some_object() file = open('test', 'wb') #this causes the error pickle.dump(o, file) file.close() I get this error: IOError: invalid mode: wb It doesn't work (neither on test server or GAE itself), apparantly because it does't have the write permission. How can I ...

Python, subprocess, devenv, why no output?

I build a Visual Studio solution from a Python script. Everything works nicely, except that I am unable to capture the build output. p = subprocess.Popen(['devenv', 'solution.sln', '/build'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = p.communicate() ret = p.returncode Here, both out and err are always empty. This ha...

creating a .mat file from python

Hi all, I have a variable exon = [[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10]]]. I would like to create a mat file like the following >> exon : [3*2 double] [2*2 double] When I used the python code to do the same it is showing error message. here is my python code import scipy.io exon = [[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10]]...

Sort string collection in Python using various locale settings

I want to sort list of strings with respect to user language preference. I have a multilanguage Python webapp and what is the correct way to sort strings such way? I know I can set up locale, like this: import locale locale.setlocale(locale.LC_ALL, '') But this should be done on application start (and doc says it is not thread-safe!...

Operations for Long and Float in Python

I'm trying to compute this: from scipy import * 3600**3400 * (exp(-3600)) / factorial(3400) the error: unsupported long and float ...

Formatting date string in Python for dates prior to 1900?

Can anyone explain the best way to format a date time string in Python where the date value is prior to the year 1900? strftime requires dates later than 1900. ...

How do I memoize expensive calculations on Django model objects?

I have several TextField columns on my UserProfile object which contain JSON objects. I've also defined a setter/getter property for each column which encapsulates the logic for serializing and deserializing the JSON into python datastructures. The nature of this data ensures that it will be accessed many times by view and template logi...

Extracting data from a CSV file in Python

I just got my data and it is given to me as a csv file. It looks like this in data studio(where the file was taken). Counts frequency 300 1 302 5 303 7 Excel can't handle the computations so that's why I'm trying to load it in python(it has scipy :D). I want to load the data in an array: Counts = [300, 302, 303] freque...

How to deal with query parameter's encoding?

I assumed that any data being sent to my parameter strings would be utf-8, since that is what my whole site uses throughout. Lo-and-behold I was wrong. For this example has the character ä in utf-8 in the document (from the query string) but proceeds to send a B\xe4ule (which is either ISO-8859-1 or windows 1252) when you click submit. ...

I'm trying to figure out how to get python to simply post the lyrics to a song.

I'm a beginner in python programming and on one of my assignments I am to use python to write a code that will say these lyrics. This old man, he played one He played knick-knack on my thumb Knick-knack paddywhack, give your dog a bone This old man came rolling home This old man, he played two He played knick-knack on my shoe Knick-k...

Python 3.1 RSS Parser?

Anyone know of a good feed parser for python 3.1? I was using feedparser for 2.5 but it doesn't seem to be ported to 3.1 yet, and it's apparently more complicated than just running 2to3.py on it. Any help? ...

Pylucene in Python 2.6 + MacOs Snow Leopard

Greetings, I'm trying to install Pylucene on my 32-bit python running on Snow Leopard. I compiled JCC with success. But I get warnings while making pylucene: ld: warning: in build/temp.macosx-10.6-i386-2.6/build/_lucene/__init__.o, file is not of required architecture ld: warning: in build/temp.macosx-10.6-i386-2.6/build/_lucene/__wrap0...