Python Idioms?

David Stanek no_spam..python at dstanek.com-NOSPAM
Tue Jun 19 03:25:07 CEST 2001


In reading through the Python source code I came across some oddities.  In
some modules, specifically threading, the instance objects are created using
a kind of factory method.
e.g.
class _X:
    pass

def X(*tupArgs, **dicArgs):
    return apply(_X, tupArgs, dicArgs)

When the class could just as easily been named X.  Is there an advantage to
doing things this way?

Also I noticed in the same module:
import sys
_sys = sys
del sys

What does this do?  You still have a reference to the module.  What
difference does it make what the name is.

David Stanek





More information about the Python-list mailing list