What you are trying to do is inherently impossible. fooit just doesn’t know how you imported it; it can even be imported in several ways. An example in my Linux box:
>>> from os.path import normpath
>>> from posixpath import normpath as normpath2
>>> normpath is normpath2
True
So, normpathand normpath2is one and the same functional object. It is not possible to display information about how they were imported.
However, sometimes this can help find the attribute of __module__your function:
>>> normpath.__module__
posixpath
>>> normpath2.__module__
posixpath
__module__ , , , .