Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Tab Completion feature #820

Closed
gasagna opened this Issue · 8 comments

5 participants

Davide Lasagna Min RK Thomas Kluyver Moritz Emanuel Beber Christian Prinoth
Davide Lasagna

Hi,

Just an idea, would it be possible to have tab completion of functions' arguments names?

Cheers

Davide

Min RK
Owner

Should be possible, I think. We would have to detect that we are inside a function call and identify that function, which I don't think we do, but presumably could.

Example, assuming you have found the function:

import inspect

spec = inspect.getargspec(func)
# only get names of keyword args:
if spec.defaults:
    kwargnames = spec.args[-len(spec.defaults):]
Thomas Kluyver
Owner

Having just tested, it seems we already can do that. I tried:

In [6]: def f(kinkajou=True):
   ...:     print kinkajou
   ...:     

In [7]: f(k
Min RK
Owner

good call, it certainly does work. I probably should have checked :). Closing.

Min RK minrk closed this
Davide Lasagna

Yes, but the current behaviour seems to show only optional arguments,

def f(koala, kinkajou=True):
    print "I'm a koala"
f(k
kaiser kinkajou= kron

Why not get completion for all arguments?

Davide

Min RK
Owner
Moritz Emanuel Beber

You can actually, e.g.,

>>> def f(a, b):
...     print a, b

>>> f(a=3, b=4)
3 4

>>> f(b=3, a=4)
4 3

that's using Python 2.7, not sure about earlier versions.

Min RK minrk referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Min RK
Owner

Good call, I had forgotten about that! It does work in 2.6, which is the earliest version supported by IPython. How's this?

Christian Prinoth
CRP commented

Hi, sorry if I refer to this very old point, but it is the only existing reference I found to tab-completion for function arguments. The current setup shows all variables in the current namespace along with the function arguments. But the latter are difficult to find if the namespace is crowded. Would it be possible to group all argument together at the beginning or something like that?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.