[Tutor] How to get all methods of "object"?
DL Neil
PyTutor at danceswithmice.info
Sat Sep 21 22:49:01 EDT 2019
On 22/09/19 2:35 PM, Cameron Simpson wrote:
> On 22Sep2019 12:12, DL Neil <PyTutor at danceswithmice.info> wrote:
>> On 22/09/19 11:29 AM, boB Stepp wrote:
>>> Python 3.7.4
>>> I tried to do this with:
>>>>>> for attribute in dir(object):
>>> print(attribute)
>> ...
>> By definition, doesn't "inheritance" mean that the sub-class includes
>> *all* of the attributes (data and code) of its super-class(es)?
>
> Unless overridden, yeah. But they don't all
Incomplete sentence? Do I sense a master-class in the offing?
Surely though, if an attribute is part of a SuperClass then it will
'appear' in the SubClass. If SubClass.x overrides SuperClass.x (or x() )
then attribute-x still appears, even if it contains different data, a
different type, or different code?
Granted that SuperClass.x is 'invisible' if SubClass.x has been defined,
but even so, instead of self.x can't we still access SuperClass.x?
(I can't think of a time when I've tried, but...)
Is there another case when a super class's attribute will not be inherited.
(again: excluding slots or other sleigh-of-hand)
>> (I'm not mentioning "slots" in a bid to preserve @boB's sanity)
>
> Too late! In both senses :-)
So sad. His parents had such high hopes for him; yet now he is condemned
to join us in the asylum known as programming...
--
Regards =dn
More information about the Tutor
mailing list