python-2.5

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

How can I list the methods in a Python 2.5 module? Question: 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 …

Total answers: 4

Check if input is a list/tuple of strings or a single string

Check if input is a list/tuple of strings or a single string Question: I’ve a method that I want to be able to accept either a single string (a path, but not necessarily one that exists on the machine running the code) or a list/tuple of strings. Given that strings act as lists of characters, …

Total answers: 9

How to parse a RFC 2822 date/time into a Python datetime?

How to parse a RFC 2822 date/time into a Python datetime? Question: I have a date of the form specified by RFC 2822 — say Fri, 15 May 2009 17:58:28 +0000, as a string. Is there a quick and/or standard way to get it as a datetime object in Python 2.5? I tried to produce …

Total answers: 6

How to decorate a class?

How to decorate a class? Question: How do I create a decorator that applies to classes? Specifically, I want to use a decorator addID to add a member __id to a class, and change the constructor __init__ to take an id argument for that member. def getId(self): return self.__id classdecorator addID(cls): def __init__(self, id, *args, …

Total answers: 8

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

How does Python's "super" do the right thing? Question: 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 …

Total answers: 5

How do I zip the contents of a folder using python (version 2.5)?

How do I zip the contents of a folder using python (version 2.5)? Question: Once I have all the files I require in a particular folder, I would like my python script to zip the folder contents. Is this possible? And how could I go about doing it? Asked By: Amara || Source Answers: Here …

Total answers: 4