interactive help on the base object
tjreedy at udel.edu
Mon Dec 9 06:00:53 CET 2013
On 12/8/2013 8:43 PM, Mark Lawrence wrote:
> On 09/12/2013 00:45, Denis McMahon wrote:
>> On Sun, 08 Dec 2013 23:48:57 +0000, Mark Lawrence wrote:
>>>>> >>> help(object)
>>>>> Help on class object in module builtins:
>>>>> class object
>>>>> | The most base type
>>>> '''The default top superclass for all Python classes.
>>>> Its methods are inherited by all classes unless overriden.
I said 'top' instead of 'bottom' or 'base' to loosen up thinking a bit.
I did not expect Mark to make a mound out of that flip.
>>> Terry's suggestion above remains odds on favourite on the grounds that
>>> there have been no other suggestions. I'll give it another day, then
>>> raise a tracker issue, unless the overwhelming smell of pot that has
>>> been drifting around this thread knocks me unconscious.
>> """ The root class for all Python classes. Its methods are inherited by
>> all classes unless overriden. """
'Root' is even better, since it does not depend on whether a tree is
drawn up or down. Thanks.
> Thanks Denis, you've reminded me why I asked in the first place. What
> methods, if any does it provide?
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__',
'__format__', '__ge__', '__getattribute__', '__gt__', '__hash__',
'__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
> Are they all abstract? etc???
> Personally I'm not really interested, but a newbie might well be and
> hence might wonder what the hell is going on.
For everything else, help lists the special name methods directly
associated with the object, along with docstrings.
Help on class C in module __main__:
| Data descriptors defined here:
| dictionary for instance variables (if defined)
| list of weak references to the object (if defined)
I think help should do the same for object
'x.__hash__() <==> hash(x)'
is equivalent to
| x.__abs__() <==> abs(x)
etc printed for help(int)
The fact that __dict__ does not exist for object but is only added for
subclasses explains why one must subclass object to get instances that
>>> o = object()
>>> o.a = 1
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
o.a = 1
AttributeError: 'object' object has no attribute 'a'
>>> c = C()
> If and only if the
> situation can be improved I'll raise an issue
I think it can be. If you prefer me to open the issue, say so.
We should look for existing issues, and closed issues that rejected change.
Terry Jan Reedy
More information about the Python-list