R Kiselev R Kiselev - 5 months ago 37
Python Question

Annoying sublime text autocompletion for Python after period (`self` keyword)

I'm using sublime text 3 for python development. I have autocompletion turned on as I type, which works. I expect, that when I type an object name followed by a period, a list of object's methods/attributes would popup. It does not happen, so I press

Tab
.

import time
time.[TAB]


What happens now, is just absolutely weird!
.
is replaced by
self.
, so I end up with

import time
timeself.


I was looking in all setting files, I tried packages
python completions
,
code intel
and
code complice
, but none of them disabled this "feature", which drives me crazy!

Finally, I have found
Jedi
package, which solved this issue for the text editor. But I still have problems in the interpreter window (package
SublimeREPL
). By the way, if I install both
Jedi
and
code complice
, the autocompletion in the REPL seems to work better, but it offers some irrelevant crap like
%%!
or
%%HTML
. And yes, if I press [TAB] twice, I still end up with
timeself.
instead of
time.
!

Does anyone know what's going on? Where this
.
->
self.
behavior is coming from? How to disable
%%!
stuff?

Answer

I would highly recommend getting rid of your other completion packages and install Anaconda (no relation to the Anaconda Python distribution). I've been using it for a couple of years now, and I absolutely love it. Basically all you need to do to set it up is provide a path for "python_interpreter" in Anaconda's settings or in your project's settings, and it just works. No taking forever to index everything like SublimeCodeIntel, and no need to set up a separate linter if you don't want to, because several linters are built-in. Virtualenvs are seamless. Anaconda will see all the modules available to the version of Python specified by "python_interpreter", so you don't need to worry about adding extra paths to the environment through settings. Make sure you copy all of the default settings file into the user settings file, then change the options as needed. Project-specific settings override user settings, so you can customize even more by editing your project.

BTW, I'm not affiliated with the project in any way, except for a minor pull request or two, I'm just a very satisfied user.

Comments