help on autosuper

Michele Simionato mis6 at pitt.edu
Mon Feb 3 10:16:23 EST 2003


Greg Chapman <glc at well.com> wrote in message news:<u7iq3v4s7skrr4tu3ragqcbf7hrcb7shc4 at 4ax.com>...
> On 26 Jan 2003 10:33:44 -0800, mis6 at pitt.edu (Michele Simionato) wrote:
> 
> >It seems "super" doesn't work the same for all special attributes: 
> >it works o.k. for "__doc__" but not for "__name__".
> >Still I don't know why, i.e. if this is the desired effect or not.

<snip explanation>

> So the behavior is basically by design, though it is a bit of a quirk that 
> super will retrieve non-descriptor data attributes.
> 

Okay, this is by design,  but then one should change pydoc:

>>> class B(object):
...    pass
>>> class C(B):
...    sup=super(B)
>>> C.sup
<super: <class 'B'>, NULL>
>>> help(C) 
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.2/site.py", line 279, in __call__
    return pydoc.help(*args, **kwds)
  File "/usr/lib/python2.2/pydoc.py", line 1505, in __call__
    self.help(request)
  File "/usr/lib/python2.2/pydoc.py", line 1541, in help
    else: doc(request, 'Help on %s:')
  File "/usr/lib/python2.2/pydoc.py", line 1336, in doc
    pager(title % (desc + suffix) + '\n\n' + text.document(thing, name))
  File "/usr/lib/python2.2/pydoc.py", line 268, in document
    if inspect.isclass(object): return apply(self.docclass, args)
  File "/usr/lib/python2.2/pydoc.py", line 1088, in docclass
    lambda t: t[1] == 'method')
  File "/usr/lib/python2.2/pydoc.py", line 1030, in spill
    name, mod, object))
  File "/usr/lib/python2.2/pydoc.py", line 269, in document
    if inspect.isroutine(object): return apply(self.docroutine, args)
  File "/usr/lib/python2.2/pydoc.py", line 1111, in docroutine
    realname = object.__name__
AttributeError: 'super' object has no attribute '__name__'




More information about the Python-list mailing list