Forum Archive

Module grabber

misha_turnbull

I was curious as to what some of the modules (as in, import {module}) actually look like. So I made this script to pull them from the app's site-packages folder.

https://gist.github.com/79be00ce58370583b65f

I'm sure it can be improved – all I ask is that you let me know so I can get the better version! :p

omz

You might want to have a look at the inspect module, particularly the getsource function.

dgelessus

I made something similar a while ago, it looks up and opens the path for a given module name.

Bonus feature: if you have text selected that looks like a module name or import statement, that module is looked up directly without asking for a name.

misha_turnbull

Thanks for the suggestions! I've implemented the inspect module and am working on something similer to the importfinder script.

https://gist.github.com/0728664ccf51b9b2bcce

pacco

Thanks for the useful tool. Python is still relatively new to me and whenever learning a new language it always helps to spend as much time as possbile reading existing code. The Python standard library modules are ideal sources (pun intended) for code to study.