Closed GoogleCodeExporter closed 9 years ago
Autocompletion in the interpreter involves the evaluation of the expression on
the left of the dot. There is no other way to provide accurate
auto-completion. In your example the expression has a side effect, hence the
outcome.
The alternative is to not provide autocompletion in the case of function calls.
Is this preferable?
Original comment by pyscripter
on 24 Sep 2010 at 9:19
> The alternative is to not provide autocompletion
> in the case of function calls. Is this preferable?
Yes, this is preferable (even though autocomplete is a cool and useful thing).
Evaluating a function when the user does not expect the function to be run can
do unwanted/unexpected things. Thus, autocompletion should be implemented so
that it does not cause a state change in the Python workspace.
I checked one of the other mature IDE's and they do not provide autocompletion
when a function is involved...I assume for the same reason being discussed
here.
Original comment by andrew.r...@gmail.com
on 24 Sep 2010 at 10:16
Fixed in version control.
No code completion over brackets.
I could still provide code completion for
a[10].
or
(1+1).
but it is going to be hard to tell whether a function call is inside the
brackets.
So from now on code completion is only provided for
somevar.attribute.attribute.
It is a pity but I accept your argument about the risk involved.
Original comment by pyscripter
on 25 Sep 2010 at 12:19
Original comment by pyscripter
on 25 Sep 2010 at 12:22
For brackets, you could take what's inside and ask Python if it's an integer.
So:
i=1
s[i].
would allow autocompletion to work.
Original comment by andrew.r...@gmail.com
on 25 Sep 2010 at 2:16
Is not as simple. First of all indices do not have to be integer. Second one
needs to consider things like
a[f(g(x))] etc.
Original comment by pyscripter
on 25 Sep 2010 at 4:16
> First of all indices do not have to be integer.
This is true. I'm saying you could take what's in the brackets and ask Python
if it's an integer. If it is, then grab its value and invoke autocompletion.
If it isn't, skip autocompletion.
I did this in an app I created that uses autocompletion and it works well:
s[i]. gives autocompletion because Python says 'i' is in integer object, and
s[f(x)]. skips autocompletion because the Python says 'f' is not an integer
object.
I use PyInt_Check(PyObject *o) to do type checking.
Original comment by andrew.r...@gmail.com
on 25 Sep 2010 at 4:40
OK. It now handles square brackets if the expression inside does not contain
parenthesis.
e.g.
mylist[a+b].
Original comment by pyscripter
on 25 Sep 2010 at 11:05
Awesome, thanks!
Original comment by andrew.r...@gmail.com
on 26 Sep 2010 at 3:33
Original issue reported on code.google.com by
andrew.r...@gmail.com
on 24 Sep 2010 at 3:33