> > > 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)>> You subclass the module metaclass. The example we were discussing was different: it subclassed the module itself, like this: >>> import re >>> class X(re): pass ... >>> X() Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: 'module' object is not callable >>> --Guido van Rossum (home page: http://www.python.org/~guido/)
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