Python3 - How do I import a class from another file

Python python at python.invalid
Mon Dec 9 04:44:20 EST 2019


Le 09/12/2019 à 09:15, R.Wieser a écrit :
...
>> You'll find that *any* form of import executes all the top-level code.
> 
> Thats certainly something I did not expect.

How could it be otherwise? Consider a module defining two
classes: Parent and Child, Child inheriting from Parent.

if you do "from the_module import Child", how could it
not execute the code defining Parent as well? Child
*depends* on Parent.




More information about the Python-list mailing list