help on autosuper
Michele Simionato
mis6+ at pitt.edu
Sat Jan 25 08:09:16 EST 2003
In his essay on type/class unification, Guido defines the following
autosuper metaclass:
--- begin autosup.py ---
class autosuper(type): #Guido's metaclass
def __init__(cls, name, bases, dic):
super(autosuper, cls).__init__(name, bases, dic)
setattr(cls,"_%s__super" % name, super(cls))
class C(object): #a simple class
__metaclass__=autosuper
--- end autosup.py ---
Notice that I have put the metaclass in a module called autosup.
Everything works as expected; however, there is some incompatibility
with pydoc:
>>> import autosup
>>> help(autosup)
Traceback (most recent call last):
File "<pyshell#1>", line 1, in ?
help(autosup)
File "C:\PYTHON22\lib\site.py", line 279, in __call__
return pydoc.help(*args, **kwds)
File "C:\PYTHON22\lib\pydoc.py", line 1510, in __call__
self.help(request)
File "C:\PYTHON22\lib\pydoc.py", line 1546, in help
else: doc(request, 'Help on %s:')
File "C:\PYTHON22\lib\pydoc.py", line 1341, in doc
pager(title % (desc + suffix) + '\n\n' + text.document(thing, name))
File "C:\PYTHON22\lib\pydoc.py", line 267, in document
if inspect.ismodule(object): return apply(self.docmodule, args)
File "C:\PYTHON22\lib\pydoc.py", line 961, in docmodule
contents.append(self.document(value, key, name))
File "C:\PYTHON22\lib\pydoc.py", line 268, in document
if inspect.isclass(object): return apply(self.docclass, args)
File "C:\PYTHON22\lib\pydoc.py", line 1093, in docclass
lambda t: t[1] == 'method')
File "C:\PYTHON22\lib\pydoc.py", line 1035, in spill
name, mod, object))
File "C:\PYTHON22\lib\pydoc.py", line 269, in document
if inspect.isroutine(object): return apply(self.docroutine, args)
File "C:\PYTHON22\lib\pydoc.py", line 1116, in docroutine
realname = object.__name__
AttributeError: 'super' object has no attribute '__name__'
Somebody can tell me what's happening, please ?
TIA,
Michele
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20030125/31fdc516/attachment.html>
More information about the Python-list
mailing list