[Python-Dev] subclass a module?

Barry A. Warsaw barry@zope.com
Fri, 31 May 2002 23:16:48 -0400


Am I freaking out, did I missing something, or was the `root' in my
root beer float tonight something other than sarsaparilla?

-------------------- snip snip --------------------
Python 2.2.1 (#1, May 31 2002, 18:34:35) 
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import string
>>> class allmodcons(string): pass
... 
>>> string
<module 'string' from '/usr/local/lib/python2.2/string.pyc'>
>>> allmodcons
<module '?' (built-in)>
-------------------- snip snip --------------------

Can I now subclass from modules?  And if so, what good does that do
me?

-------------------- snip snip --------------------
>>> dir(allmodcons)
[]
>>> allmodcons.whitespace
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'whitespace'
>>> string.whitespace
'\t\n\x0b\x0c\r \xa0'
>>> 
-------------------- snip snip --------------------

stickin'-to-herbal-tea-and-dr.-pepper-ly y'rs,
-Barry