Day: September 24, 2003

  • __magic__ Variable Conventions

    Via PythonWare’s Daily Python-URL, Alan Green covers module level __magic__ variables in Python.  I’ll have to admit that I knew about some of them and was clueless about others.  For example, __dict__ is a module global read-only dictionary.  You can also explicitly set the public names of a module with __all__.

    I’m guilty of using several __magic__ veriables that aren’t explicitly defined in the language reference.  Most came from looking at the source code of third party Python modules, particularly those by Mark Pilgrim.  If it’s good enough for Mark, it should work for me, right?  Here’s a list of __magic__ variables that you’ll commonly find in modules written by myself and others:

    • __license__: String.  Useful for identifying the license of the code.  Examples: “GPL”, “LGPL”, “BSD”, etc.
    • __history__: String.  Excellent for keeping track of changes between versions.  Similar to a changelog.txt file.  See Mark’s feedparser for an example.  This works for me, but could get out of hand for larger modules with multiple authors.
    • __copyright__: String.  Copyright info goes here.  I’ve also seen llicense info here (for example xmltramp by Aaron Swartz).

    Are there other useful but unofficial __magic__ variables that are useful?  Email me and I’ll append them to the list.  Would it be worthwhile to compile a list of commonly used but unofficial variables into a PEP?  It would be excellent if pydoc took advantage of this extra information.

  • Python 2.3.1

    Python 2.3.1 has been released:

    Python 2.3.1 is a bugfix release of Python 2.3. No new features have been added. Instead, this release is the result of two months of bug hunting. A number of obscure bugs that could cause crashes have been fixed, as well as a number of memory leaks.

    Excellent.  I remember reading on python-dev that they were trying to push 2.3.1 out the door pretty quickly, and here it is.  Thanks again to the Python developers and bug squashers for all the hard work.