[Python-Dev] subclass a module?

David Abrahams David Abrahams" <david.abrahams@rcn.com
Sat, 1 Jun 2002 08:00:53 -0400


From: "Guido van Rossum" <guido@python.org>


> > Can I now subclass from modules?
> 
> It's a bug IMO.  
> 
> > And if so, what good does that do me?
> 
> None whatsoever.  The resulting class cannot be instantiated.

Really?

>>> import re
>>> class X(type(re)):
...     def hello(): print 'hi'
...
>>> newmod = X()
>>> newmod.hello
<bound method X.hello of <module '?' (built-in)>>