I have three modules a.py, b.py and c.py. The a.py module is the base one. What I want to achieve is to have different behaviour when a.py is imported by b.py and when a.py is imported by c.py. For example:
a.py
def ab():
return 5
def ac():
return 6
if __nameoftheimportmodule__ == 'b':
x = ab()
elif __nameoftheimportmodule == 'c':
x = ac()
else:
pass
Therefore, calling b.py like this:
b.py
import a
print(a.x)
will return 5 (and for c.py it would return 6).
And my question is whether such a design is possible (e.g. whether there exists such a function that behaves like the above-mentioned nameoftheimportmodule)?