+ 1

[solved] [Python inheritance] Is this normal?

I was testing different class stuff along with inheritance and realised that inherited base class stuff is not in derived class' __dict__ for some reason. Is it normal? https://code.sololearn.com/c8zFT76ppmPo/?ref=app

16th Feb 2021, 4:10 PM
#0009e7 [get]
#0009e7 [get] - avatar
2 Answers
+ 5
sure it's normal... Derived class will resolve Base class properties/method at run time: as you doesn't overide any methods in Derived declaration, you'll get the Base constructor but the Derived __dict__ is empty.
16th Feb 2021, 4:28 PM
visph
visph - avatar
+ 1
visph, thanks for your explanation! I used to forget "dir" function and used "__dict__" argument instead because I called to memory it first, which was wrong choice. Now I found "dir" and "getattr" functions that do exactly what I want.
16th Feb 2021, 4:50 PM
#0009e7 [get]
#0009e7 [get] - avatar