These are chat archives for ipython/ipython

14th
Feb 2016
Yuri Numerov
@Achifaifa
Feb 14 2016 05:22
I'm having a go at fixing issue #9114 and I found some weird syntax in completer.py and completerlib.py, can anyone help with this?
Things like if word[:1] == "%": if not "%" in word[1:]: return word[1:] + "%"
(Isn't word[:1] the same as word[0]?)
Or things like list[:]=[] (Same as list=[])
I've been tempted to cleaning the code up a bit but I'm not sure if that'd be cool with everyone
Min RK
@minrk
Feb 14 2016 08:15
list[:] = is not the same as list=. One is in-place, the other allocates a new object and detaches the reference from the existing variable.
The same goes for the first example - word:1 is correct if len(word) is 0, while word[0] raises IndexError.
Yuri Numerov
@Achifaifa
Feb 14 2016 08:17
Oh ok, I didn't know that, thanks :O
Min RK
@minrk
Feb 14 2016 08:52
A lot of that code is old and could use cleaning up. But completion is pretty fiddly, so I'd be careful about it.
epifanio
@epifanio
Feb 14 2016 19:54
The same goes for the first example - word:1 is correct if len(word) is 0, while word[0] raises IndexError. <— is now in my notes too!