I would like to get ahold of my module (to list all function names), even when using cProfile. How can I do that?
To clarify I'm using some introspection in my own module, but sys.modules[__main__]
does of course not return my own module any more when running with -m cProfile
.
To reproduce, create modtest.py:
#!/usr/bin/env python3
import sys
print(sys.modules[__name__])
Run it like so:
$ ./modtest.py
<module '__main__' from './modtest.py'>
$ python -m cProfile ./modtest.py
<module 'cProfile' from '...cProfile.py'>
How can I get that last line to say from './modtest.py'
?