python-2.5

Tell if python is in interactive mode

In a python script, is there any way to tell if the interpreter is in interactive mode? This would be useful, for instance, when you run an interactive python session and import a module, slightly different code is executed (for example, log file writing is turned off, or a figure won't be produced, so you can interactively test your pro...

Python win32crypt.CryptProtectData difference between 2.5 and 3.1?

I'm trying to hash a password to dump into a .rdp file. I found a site that (more or less) shows how to do that here but it doesn't work in 3.1. In 2.5.4 I get this: >>> import win32crypt >>> import binascii >>> pwdHash = win32crypt.CryptProtectData(u"password",u'psw',None,None,None,0) >>> print str(binascii.hexlify(pwdHash)).upper() 0...

convert string of millisecond into datetime in python

I am a newbie in Python. I want to subtract interval time from my log file, but the problem is I cannot convert millisecond string of log file into datetime format. For example, I have 15:55:05.12345 and I want to remove 5.12345 seconds from this string, and show result of 15.55.00.00000 in Python. How can I do that? Currently, I am usin...

How can I use json module in google app engine ?

json module was added in python 2.6 but GAE supports 2.5 only. How can I use it there? ...

Asynchronous database update in Django?

I have a big form on my site. When the users fill it out and submit it, most of the data just gets dumped to the database, and then they get redirected to a new page. However, I'd also like to use the data to query another site, and then parse the results. That might take a bit longer. It's not essential that the user sees these results ...

Python 2.4 inline if statements

I am setting up an existing django project on a dreamhost web server, so far I have got everything to work correctly. However I developed under python 2.5 and dreamhost by default uses python 2.4. The following line seems gives a syntax error because of the if keyword: 'parent': c.parent.pk if c.parent is not None else None ...

Until when will Python 2.5 be supported?

Apparently Python only supports 2 minor versions (like 2.X), so that would mean Python 2.5 would get phased out when Python 2.7 comes out (in June 2010?) Is this correct? PEP 356 -- Python 2.5 Release Schedule doesn't give much answers to this question. ...

How to write full chat server / client using python 2.5

Hi All, I want to write server/client chat protocol using python-2.5 . I want to make protocol similar to yahoo messenger or google-talk. Please suggest me how to start. Thanks Reetesh Nigam ...

Does urllib or urllib2 in Python 2.5 support https?

Thanks for the help in advance. I am puzzled that the same code works for python 2.6 but not 2.5. Here is the code import cgi, urllib, urlparse, urllib2 url='https://graph.facebook.com' req=urllib2.Request(url=url) p=urllib2.urlopen(req) response = cgi.parse_qs(p.read()) And here is the exception I got Traceback (most recent call l...

Python - Code snippet not working on Python 2.5.6, using IDLE

Hello, everyone I am using a piece of self-modifying code for a college project. Here it is: import datetime import inspect import re import sys def main(): # print the time it is last run lastrun = 'Mon Jun 8 16:31:27 2009' print "This program was last run at ", print lastrun # read in the source code of itsel...

Python: shutil.copytree , lack of ignore arg in python 2.5

Short of essentially rewriting copytree to accept an ignore callback, what is a simple way to achieve this in versions prior to python 2.6? (I don't want to stray from my debian packages) ...

header filtering using python

i want to filter some headers in a wireshark capture (converted to text format) so i can analyse these set of headers.i need a python script to do this. any help would be appreciated ...

Subclassing int in Python

I'm interested in subclassing the built-in int type in Python (I'm using v. 2.5), but having some trouble getting the initialization working. Here's some example code, which should be fairly obvious. class TestClass(int): def __init__(self): int.__init__(self, 5) However, when I try to use this I get: >>> a = TestClass()...

Python 2.5 Import dll AttributeError

I have a program that runs peachy in Py2.4. I import the TobiiPlugin.dll file and then run my scripts. import TobiiPlugin as tobii tobii.setGazeSubjectProfile(3, 0) However, when I moved the code to Py2.5 it gets angry at me and I get Traceback (most recent call last): File "C:\tobiiDll\TobiiPlugin\Debug\logger_speech.py", line 27...

Python 2.5 Windows Binaries?

I need to test an issue that occurs on Windows with Python 2.5, but the releases page doesn't link to a binary for 2.5. Is there anywhere I could find a copy? ...

python print not functioning correctly after using curses

I have created a simple gui with curses. However, when the curses menu is finished the print function does not print anything to screen until the main program exits. In the example below, when calc.py is run, the text "Directory list ok" is printed to the screen after the foo(calcDirs) is run. If I comment out the line folderSelection....

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...

Possible to do ordered dictionary in python 2.5 (due to GAE)?

I'm new to Python, and using Google App Engine, which is currently running only Python 2.5. Are there any built-in ways of doing an ordered dictionary, or do I have to implement something custom? ...

Using HTTPSConnection in python

Hello, I am trying to use HTTPS connection for certificate validation,using PEM certificate. I am sure the certificate is good. I have used the same certificate with "wget" in linux. Here is the part of code i am using for accessing server, def ConnectServer() host = "*.com" c_file = cert_file conn = httplib.HTTPSConnection(ho...

Override reversed(...) in Python 2.5

I need a custom __reverse__ function for my class that I am deploying on App Engine, so it needs to work with Python 2.5. Is there a __future__ import or a workaround I could use? Subclassing list won't work, as I need my class to be a subclass of dict. EDIT: Using OrderedDict will not solve the problems, because the dict keys are not...