Easy ways to investigate unknown Python APIs
Posted
by jedi_coder
on Stack Overflow
See other posts from Stack Overflow
or by jedi_coder
Published on 2010-06-14T15:42:58Z
Indexed on
2010/06/14
18:32 UTC
Read the original article
Hit count: 211
When studying a snippet of unknown Python code, I occasionally bump into the
varName.methodName()
pattern.
To figure out what's this, I shall study the code more, find where varName was instantiated, find its type. So if varName proves to be an instance of ClassName class, I would knew that methodName() is a method of ClassName.
Sometimes varName == self and methodName() is a method of this class, or a method inherited from some other class, if the current class is subclassing some other classes.
Are there quick ways / tools that could take 'methodName' as input, scan over all installed Python modules and show which classes have methodName()?
The closest thing related to this I know of is ipython. If I type a class name, then dot ('.') then TAB, it can show the class members. Instead of a class I could use a name of an object (which is an instance of a certain class) and it would work too. As soon as I choose a method name from the provided options, I can type '?' or '??' and get some help if there's a docstring.
I wonder if ipython can do some intelligent scanning based only on 'methodName' string.
If you know alternatives to ipython that could possibly help with this, please do suggest them.
© Stack Overflow or respective owner