Issue 14782: Tab-completion of callables displays opening paren (original) (raw)
Issue14782
Created on 2012-05-11 12:16 by wpettersson, last changed 2022-04-11 14:57 by admin.
Messages (4) | ||
---|---|---|
msg160412 - (view) | Author: w.pettersson (wpettersson) | Date: 2012-05-11 12:16 |
With tab completion enabled via rlcompleter and readline, tab-completion will assume anything that is callable (by callable(val)) is going to be called. For example, the below code defines a class "CCC" that is callable and has a static function. However, typing >>> CC and then pressing tab results in the following. >>> CCC( Note the extra parentheses. It would be nice if these weren't added if the object also has some other reasonable choices. However, I don't know what would be "reasonable" here. Somehow we'd have to detect whether a callable class has static methods, possibly via dir() or directly checking class.__dict__ but at this point I am not comfortable enough with python to suggest decent solutions. >>> class CCC: ... def __call__(self): ... print "call" ... @staticmethod ... def f(a): ... print "Static",a ... >>>CC >>>CCC( | ||
msg160420 - (view) | Author: Éric Araujo (eric.araujo) * ![]() |
Date: 2012-05-11 16:41 |
This annoys me too, for all callable objects actually (e.g. I type "help(someprefix" then Tab then I have to delete the "(" before typing ")" and Enter), but I think it was a deliberate change. I may have the original bug report open in a browser tab at home, I’ll check. | ||
msg160633 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2012-05-14 16:11 |
It's issue 449227. | ||
msg265472 - (view) | Author: Martin Panter (martin.panter) * ![]() |
Date: 2016-05-13 12:51 |
FWIW, count me against the automatic brackets as well. Another way it gets in the road: >>> class C(object(. . . In Issue 5062, Carl thought there might be a switch to turn the behaviour off. Perhaps we could add some sort of configuration option. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:30 | admin | set | github: 58987 |
2016-05-13 12:51:25 | martin.panter | set | messages: + |
2015-02-11 10:56:25 | martin.panter | set | nosy: + martin.panter |
2012-05-14 16:11:38 | r.david.murray | set | nosy: + rnd0110, dieresys, facundobatista, pitrou, gpolo, r.david.murray, georg.brandlmessages: + |
2012-05-11 16:41:32 | eric.araujo | set | title: Tab-completion of classes displays opening paren -> Tab-completion of callables displays opening paren |
2012-05-11 16:41:09 | eric.araujo | set | nosy: + eric.araujomessages: + title: Tabcompletion of classes with static methods and __call__ has extra bracket -> Tab-completion of classes displays opening paren |
2012-05-11 12:16:25 | wpettersson | create |