from pack.mod import f
How to get from object f information about import - \'pack.mod\'
\'pack.mod\'
I can get it using f.__module__
f.__module__
You want the __name__ attribute from __module__:
__name__
__module__
In [16]: import inspect In [17]: inspect.getmodule(MyObject).__name__ Out[17]: 'lib.objects.MyObject'