python

Python 2.6 to 2.5 cheat sheet

I've written my code to target Python 2.6.5, but I now need to run it on a cluster that only has 2.5.4, something that wasn't on the horizon when I wrote the code. Backporting the code to 2.5 shouldn't be too hard, but I was wondering if there was either a cheat-sheet or an automated tool that would help me with this. For some things, li...

Python: How to distinguish between inherited methods

Newbie Python question. I have a class that inherits from several classes, and some of the specialization classes override some methods from the base class. In certain cases, I want to call the unspecialized method. Is this possible? If so, what's the syntax? class Base(object): def Foo(self): print "Base.Foo" def B...

How google docs shows my .PPT files without using a flash viewer?

I want to show .ppt (PowerPoint) files uploaded by my user on my website. I could do this by converting them into Flash files, then showing the Flash files on the web page. But I don't want to use Flash to do this. I want to show it, like google docs shows, without using Flash. I've already solved the problem for .pdf files by convertin...

Grab elements inside parentheses

How can I grab the elements inside the parentheses and put them in a file? me (I) you (You) him (He) her (She) Thanks in advance, Adia ...

Panda3D and wxpython

I am very new to Panda3D and I have been trying to find a simple example of panda3d working together with wxpython (as its main frame, for instance). The forums talk about such possibility, but I am yet to find a simple example. Can anyone please point me to a good and simple example of such code? Thanks ...

Getting rid of \x## in strings (Python)

I need to extract a description from a file, which looks like this: "TES4!\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00HEDR\x0c\x00\xd7\xa3p?h\x03\x00\x00\x00\x08\x00\xffCNAM\t\x00Martigen\x00SNAM\xaf\x00Mart's Mutant Mod - RC4\n\nDiverse creatures & NPCs, new creatures & NPCs, dynamic size and stat scaling...

Ways to implement Janrain Engage (RPXNow) on Google App Engine?

What a some possible solutions to best implement Janrain Engage (RPX Now) on Google App Engine? ...

compatibility between CPython and IronPython cPickle

Hi all, I was wondering whether objects serialized using CPython's cPickle are readable by using IronPython's cPickle; the objects in question do not require any modules outside of the built-ins that both Cpython and IronPython include. Thank you! ...

How do I extract a zip file with Python's ZipFile module?

Possible Duplicate: Unziping files in python How do I extract a zip file with Python's ZipFile module? An example script would be awesome! ...

Stop-word elimination and stemmer in python

Hi, I have a somewhat large document and want to do stop-word elimination and stemming on the words of this document with "Python".Does anyone know an of the shelf package for these? If not a code which is fast enough for large documents is also welcome. Thanks ...

negative numbers in python

Hi, everyone I've found some strange behaviour in python regarding negative numbers: >>> a = -5 >>> a % 4 3 Could anyone explain what's going on? ...

How to post text to myspace activity stream by myspace python sdk

I try to post a text to activity stream's myspace, by using python sdk from myspace 's website . Anyone has some example or what i need to use more? ...

Caesar Cipher in python (Please help me where am i going wrong)

The error which i am getting is Traceback (most recent call last): File "imp.py", line 52, in <module> mode = getMode() File "imp.py", line 8, in getMode mode = input().lower() File "<string>", line 1, in <module> NameError: name 'encrypt' is not defined Below is the code. # Caesar Cipher MAX_KEY_SIZE = 26 def getMod...

How do I read the number of files in a folder using Python?

How do I read the number of files in a specific folder using Python? Example code would be awesome! ...

How to change text on gtk.label in frequent intervals - PyGTK

I am coding a desktop application which shows contents from text file in a gtk.label, i update that text file, say once in every 15 mints. Are are there any methods to make the application to read the text file in constant intervals and display it without restarting the window ...

Using Python code coverage tool for understanding and pruning back source code of a large library

My project targets a low-cost and low-resource embedded device. I am dependent on a relatively large and sprawling Python code base, of which my use of its APIs is quite specific. I am keen to prune the code of this library back to its bare minimum, by executing my test suite within a coverage tools like Ned Batchelder's coverage or fi...

Run Django on multiple ports

Could someone tell me how I can run Django on two ports simultaneously? The default Django configuration only listens on port 8000. I'd like to run another instance on port xxxx as well. I'd like to redirect all requests to this second port to a particular app in my Django application. I need to accomplish this with the default Django ...

Encoding error in Python with Chinese characters

I'm a beginner having trouble decoding several dozen CSV file with numbers + (Simplified) Chinese characters to UTF-8 in Python 2.7. I do not know the encoding of the input files so I have tried all the possible encodings I am aware of -- GB18030, UTF-7, UTF-8, UTF-16 & UTF-32 (LE & BE). Also, for good measure, GBK and GB3212, though th...

django, python: reload function in shell

Hello, I work in the django IPython-shell, which can be started with manage.py shell. When i load an extern function in the shell for testing, everything is alright. But when i make changes to the function, the shell still has the old version of the function. Even if i make a new import. Does anyone know how to reload the actual versio...

Maintaining a Python Object when embedding in C

Due to refactoring/reworking on a controller I've had to embed a Python Interpreter inside a C application. I can now call python functions and pass/get Objects into Python fine. The python code is a controller for a robot (currently simulated), this now needs make use of some C code for comparisons I'm making. Previously the Python ...