barry@zope.com (Barry A. Warsaw): > Can I now subclass from modules? And if so, what good does that do > me? This seems to be a side effect of two things: (1) Python 2.2 will accept anything as a base class whose type is callable with the appropriate arguments, and (2) types.ModuleType doesn't seem to care what arguments you give it: Python 2.2 (#14, May 28 2002, 14:11:27) [GCC 2.95.2 19991024 (release)] on sunos5 Type "help", "copyright", "credits" or "license" for more information. >>> from types import ModuleType >>> ModuleType() <module '?' (built-in)> >>> ModuleType(42) <module '?' (built-in)> >>> ModuleType("dead", "parrot") <module '?' (built-in)> >>> ModuleType("nobody", "expects", "the", "spanish", "base", "class") <module '?' (built-in)> >>> So your class statement is simply creating an empty module. An interesting feature of the new scheme is that the "class" statement can be used to create things which don't even remotely resemble classes. Brain-explosion for the masses! Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4