[IPython-user] Parsing issue (maybe).

Ville Vainio vivainio at gmail.com
Fri Jan 13 05:05:01 CST 2006


On 1/13/06, Fernando Perez <Fernando.Perez at colorado.edu> wrote:

> I'd like to hear if Robert is willing to leave it on for a while, and see how
> it goes.  Ideally, %autocall should ALWAYS do the right thing, with the only

Shouldn't we use inspect.getargspec to "do the right thing" in smart
autocalling?

Y:\s60]|17> import inspect
Y:\s60]|18> def f(x,y=10):
       |..>     pass

[Y:\s60]|19> inspect.getargspec(f)
        <19> (['x', 'y'], None, None, (10,))

Note how we see that y has default value 10 (first arg, counting from
the right).

We should use default values to autocall functions that require no
arguments, but can be called with some...

Docstring for inspect.getargspec:
    Get the names and default values of a function's arguments.

A tuple of four things is returned: (args, varargs, varkw, defaults).
'args' is a list of the argument names (it may contain nested lists).
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'defaults' is an n-tuple of the default values of the last n arguments.



--
Ville Vainio    http://tinyurl.com/2prnb
  Can't you see the world is burning
  Can't you feel its Fire burning
  Don't you know we all are burning
  The Fire of Life       -- R.N.Taylor / Changes




More information about the IPython-user mailing list