[Python-Dev] a strange case

Guido van Rossum guido@python.org
Sun, 18 May 2003 16:42:34 -0400


> "Why in the world would you want callable modules you ask?"  I 
> don't have a real need, but I often see the line blurred between package, 
> module, and class.

Please don't try to blur the line between module and class.  This has
been proposed many times, and the net result IMO is always more
confusion and no more power.  This is also why in 2.3, modules are no
longer subclassable.

If you really need to have a module that has behavior beyond what a
module can offer, the officially sanctioned way is to stick an
instance of a class in sys.modules[__name__] from inside the module's
code.

(I would explain more about *why* I think it's a really bad idea, but
I'm officially on vacation.)

--Guido van Rossum (home page: http://www.python.org/~guido/)