Accessing parent objects

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Mar 25 10:40:04 EDT 2018


On Sun, 25 Mar 2018 08:09:02 -0600, Ian Kelly wrote:

> On Sun, Mar 25, 2018 at 5:46 AM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> On Sun, 25 Mar 2018 06:11:53 -0500, D'Arcy Cain wrote:
>>> It accesses the parent class.  I want to access the parent object.
>>
>> Ah. Well, no wonder it doesn't work: you're confusing the OO
>> inheritance concept of "parent" (a superclass) with whatever
>> relationship you have between one instance and another instance. Just
>> because they share the same name doesn't make them the same concept.
> 
> No, he's merely confusing the concept of nested classes in Python with
> nested classes in Java, which actually supports this magic.
> 
> To the OP: Python isn't Java. Nested classes in Python work like
> "static" nested classes in Java.


TIL, thanks.


(I'm not sure exactly what I've learned, but I learned *something* about 
nested classes in Java.)

-- 
Steve




More information about the Python-list mailing list