How does Python resolve global variables in calls between packages, especially in cases there are global variables with the same name present?
For example. Let there ba a package P1
containing BaseClass
. Let there be two packages P2
and P3
, containing classes Derived1
and Derived2
that inherit BaseClass
correspondingly. Also, let P2
and P3
both contain variable named gvar
(for example, defined in their init.py files).
Both of derived classes in their constructors have a call to baseClass
constructor through super
.
If in BaseClass
constructor there is a reference to gvar
, what would happen? Is there a way to ensure that during instantiation of Derived1
gvar
from P2
would be used?
Why am i bothering with global variables: in my real life case there are tens of classes in P1
and P2
, and i would like to avoid changing them all (to add package-specific gvar
to their definitions, or adding another common ancestor with it).