I have three modules:
in_mod.py
class IN(object):
def __init__(self):
print("i am the original IN")
module1.py
from in_mod import IN
class C(object):
def __init__(self):
cl = IN()
and module2.py
from module1 import C
class IN2(object):
def __init__(self):
print("I am the new IN")
C()
import in_mod
in_mod.IN = IN2
C()
import module1
module1.IN = IN2
C()
I get the desired behaviour of monkey-patching out the IN
class and replacing it with the IN2
class when I use module1.IN = IN2
.
I would like to understand what the underlying difference between in_mod.IN = IN2
and module1.IN = IN2
is in this context.
I am referencing a related post.