[BangPypers] Is there a way to find the import originator?
gora at mimirtech.com
Tue Jul 15 12:00:22 CEST 2014
On 15 July 2014 15:25, Nitin Kumar <nitin.nitp at gmail.com> wrote:
> Hi All,
> Say there are 3 files.
> a.py and b.py uses *import c* (which is the third python file c.py)
> is there a way we can know inside c.py that whether its a or b who is doing
> the importing?
You can use the inspect module to get this information, e.g., see
IMHO it is not good design for a module to depend on who is calling
it. If you need that, pass a parameter to __init__
More information about the BangPypers