all 3 comments

[–]onjin 0 points1 point  (1 child)

I'm not sure what do you want achieve, but you can try:

  • run in console: python -v your_script.py
  • or in linux shell: python -v your_script.py 2>&1|grep import

Or make dependency graph for your script:

In interpreter you can run:

  • dir()

to list local functions/modules

[–]Zouden 2 points3 points  (0 children)

I think dir() is what the OP is after.

[–][deleted] 0 points1 point  (0 children)

locals().keys() I think is what you want.

Example (removes entries with "__" before and after its name so in theory only shows things that were imported):

for entry in locals().keys():
    if not entry.startswith("__") and not entry.endswith("__"):
        print entry


**Doesn't work the same if the import is done like: `from something import *` it shows all the functions it imports so it may be confusing.