Given a Python class, how can I inspect and find the place in my code where it is defined?
python
Solution
sys.modules[MyCls.__module__].__file__
or
inspect.getsourcefile(MyCls)
There are more `__xxx__` attributes on various objects you might find useful.
Problem
I'm building a debugging tool. IPython lets me do stuff like ``` MyCls?? ``` And it will show me the source.