python-2.5

How to make nntplib author name human readable?

python NNTPLib is giving me author name such as , "=?Utf-8?B?RGVubmlzIEJhc2hhbQ==?= < [email protected] >" (Quotes for clarity). How do i encode this text in human readable format? ...

Getting a list of all modules in the current package

Here's what I want to do: I want to build a test suite that's organized into packages like tests.ui, tests.text, tests.fileio, etc. In each __init__.py in these packages, I want to make a test suite consisting of all the tests in all the modules in that package. Of course, getting all the tests can be done with unittest.TestLoader, bu...

How does Python's "super" do the right thing?

I'm running Python 2.5, so this question may not apply to Python 3. When you make a diamond class hierarchy using multiple inheritance and create an object of the derived-most class, Python does the Right Thing (TM). It calls the constructor for the derived-most class, then its parent classes as listed from left to right, then the grandp...

Poplib not working correctly?

I want to get all the messages from my gmail inbox, but I am facing 2 problems. It does not get all the emails, (as per the count in stat function) The order of emails it get is random. I am unsure if its the problem with poplib or gmail pop server. What am I missing here? ...

Python Class Decorator

In Python 2.5, is there a way to create a decorator that decorates a class? Specifically, I want to use a decorator to add a member to a class and change the constructor to take a value for that member. Looking for something like the following (which has a syntax error on 'class Foo:': def getId(self): return self.__id class addID(or...

How to use time > year 2038 on official Windows Python 2.5

The official Python 2.5 on Windows was build with Visual Studio.Net 2003, which uses 32 bit time_t. So when the year is > 2038, it just gives exceptions. Although this is fixed in Python 2.6 (which changed time_t to 64 bit with VS2008), I'd like to use 2.5 because many modules are already compiled for it. So here's my question - is the...

Can I make Python 2.5 exit on ctrl-D in Windows instead of ctrl-Z?

I'm used to ending the python interactive interpreter using Ctrl-d using Linux and OS X. On windows though, you have to use Ctrl-z and then enter. Is there any way to use Ctrl-d? ...

How to include and use .eggs/pkg_resources within a project directory targeting python 2.5.1

I have python .egg files that are stored in a relative location to some .py code. The problem is, I am targeting python 2.5.1 computers which require my project be self contained in a folder (hundreds of thousands of OLPC XO 8.2.1 release laptops running Sugar). This means I cannot just ./ez_install to perform a system-wide setuptools/...

How can I list the methods in a Python 2.5 module?

I'm trying to use a Python library written in C that has no documentation of any kind. I want to use introspection to at least see what methods and classes are in the modules. Does somebody have a function or library I can use to list the functions (with argument lists) and classes (with methods and member variables) within a module? I...

how to add json library

i am new to python, on my Mac, when i issue command User:ihasfriendz user$ python main.py Traceback (most recent call last): File "main.py", line 2, in <module> import json ImportError: No module named json I get error on json. how to add this library? i'm using 2.5 (the default came with leopard) ...

python import error

I'm trying to use some python-2.1 code to control another program (ArcGIS). The version of python I am using is 2.5. I am getting the following error message when I run the code. <type'exceptions.ImportError'>: No module named win32api Failed to execute (polyline2geonetwork2). I tried installing pywin32-214.win32-py2.5.exe but I still...

Extracting decimals from a number in Python

I am writing a function to extract decimals from a number. Ignore the exception and its syntax, I am working on 2.5.2 (default Leopard version). My function does not yet handle 0's. My issue is, the function produces random errors with certain numbers, and I don't understand the reason. I will post an error readout after the code. Func...

problem when re-running program

I have a fairly simple python loop that calls a few functions, and writes the output to a file. To do this is creates a folder, and saves the file in this folder. When I run the program the first time with a unique file name, it runs fine. However, if I try to run it again, it will not work and I do not understand why. I am quite certai...

getting previously typed commands in python

I'm using python 2.5 in windows on a macbook pro with IDLE. How do I get previously typed commands in the python shell? In other operating systems I've managed to do this using 'ctrl' + 'up arrow' or a similar combination. I've tried all likely combinations without success. Thanks. ...

A case of outwardly equal lists of sets behaving differently under Python 2.5 (I think ...)

Four years ago I wrote a Sudoku puzzle solver, and now I'm trying to understand how it works so that I can reuse parts of it for a KenKen puzzle solver. I thought I'd better compactify loops into list comprehensions and pick more self-explanatory names for variables. There's a class Puz which contains the input puzzle as a list of (8...

What are the advantage and disadvantages of using a list comprehension in Python 2.54-6?

I've heard that list comprehensions can be slow sometimes, but I'm not sure why? I'm new to Python (coming from a C# background), and I'd like to know more about when to use a list comprehension versus a for loop. Any ideas, suggestions, advice, or examples? Thanks for all the help. ...

cygwin version of idle has erroneous I/O handling

I'm using idle (python 2.5) via cygwin on a windows vista machine and when I try to open an already existing .py file I see the full file path /home/aaron/C:/cygwin/home/aaron/script.py on the banner of the freshly openned file window when I expect simply /home/aaron/script.py In addition, the file appears blank which makes sense...b...

Cannot use Python 2.6 C interface anymore, but 2.5 works.

I just noticed that I cannot use the Python 2.6 dll anymore. Python 2.5 works just fine. import ctypes py1 = ctypes.cdll.python25 py2 = ctypes.cdll.python26 # ctypes.cdll.LoadLibrary("libpython2.6.so") in linux py1.Py_Initialize() py2.Py_Initialize() # segmentation fault in Linux py1.PyRun_SimpleString("print 'hello world'") # this ...

Python 2.6 bindings for SVN 1.6.6

I'm trying to install Trac 0.11 on Windows XP with Python 2.6 and VisualSVN server (Subversion 1.6.6) but I can't seem to find working bindings. ...

How to install Python ssl module on Windows?

The Google App Engine Launcher tells me: WARNING appengine_rpc.py:399 ssl module not found. Without the ssl module, the identity of the remote host cannot be verified, and connections may NOT be secure. To fix this, please install the ssl module from http://pypi.python.org/pypi/ssl . I downloaded the package and it contained ...