How to find where a function was imported from in Python?
Instead of
from bar import *
use
from bar import foo
Using the from ... import *
syntax is a bad programming style precisely because it makes it hard to know where elements of your namespace come from.
foo.__module__
should return bar
If you need more info, you can get it from sys.modules['bar']
, its __file__
and __package__
attributes may be interesting.
Try this:
help(foo.func_name)