tags:

views:

90

answers:

4

Suppose I have a function. I just want to print out what arguments are available.

+5  A: 

Use inspect.getargspec() to find out.

Ignacio Vazquez-Abrams
+1  A: 

I see that someone has already offered the answer i had in mind, so i'll suggest a purely practical one. IDLE will give you a function's parameters as a 'tooltip'.

This should be enabled by default; the tooltip will appear just after you type the function name and the left parenthesis.

To do this, IDLE just accesses the function's doc string, so it will show the tooltip for any python function--standard library, third-party library, or even a function you've created earlier and is in a namespace accessible to IDLE.

Obviously, this is works only when you are working in interactive mode in IDLE, though it does have the advantage of not requiring an additional function call.

doug
A: 

if you use IPython (as you absolutely should), use

foo?

to see the documentation, including what the function expects, and:

foo??

to see the above documentation plus the source code (if available)

bgbg
just out of curiosity, what's wrong with this answer?
bgbg
A: 

The help function does this.

All you have to do is put in docstrings for your functions.

S.Lott