Frage

I've been trying to get used to pydev for a couple of days now, and I really like it, but if I keep the auto-import option on, it keeps importing for example from test.test_iterlen import len (and many others) whenever I want a len(something) even though it's not necessary.

On the other hand if I completely turn the auto-import feature off, when I do a len(something), it just keeps inserting empty/blank lines before the current line and it's really annoying.

Any idea what might be causing it? Either the non necessary import or the empty line one.

 Eclipse: Indigo Service Release 1
 Eclipse platform: 3.7.1 
 PyDev: 2.3.0.2011121518 
 Python: 3.2.2

Many thanks!

War es hilfreich?

Lösung

The auto-import works by going through what's called the 'code completion (ctx insensitive)'... here the major issue seems to be that you're requesting the code-completion for 'len' and it's defined in many other places (and you end up choosing one of those).

So, I think in your case, if you usually do completions for short names, a better approach could be raising the number of chars to show those completions (by default it'll bring those completions when at least 2 chars are available).

You can configure those at:

window > preferences > pydev > editor > code completion (ctx insensitive and common tokens).

And change the number of chars to a higher number (as you're probably requesting the completion with 2 chars to get the len, you may want to put that request in 3, or maybe 4 chars).

Another possible approach could be putting 'len' in the list of 'common tokens' (in that same preferences page), so, it'd bring that completion while you're typing and you'd just need to select it, without actually requesting a completion.

As for the problem you reported when leaving the auto-import off, I couldn't reproduce it (i.e.: it didn't add any empty lines), so, it'd be nice if you could report that as a bug in the PyDev bug tracker with better instructions (i.e.: source file and steps to reproduce).

Andere Tipps

A popup list should appear with the code completion. Scroll down to the len(object) choice. With Python 2.7 I'm not able to recreate the weirdness you describe. There may be some strange Py3 behavior.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top