Eclipse PyDev 自动导入出现故障
我已经尝试习惯 pydev 几天了,我真的很喜欢它,但如果我保持自动导入选项,它会继续导入,例如 from test.test_iterlen import lenlen(something)
时,我都会使用 code> (以及许多其他),即使这不是必需的。
另一方面,如果我完全关闭自动导入功能,当我执行 len(something) 时,它只会在当前行之前不断插入空/空行,这真的很烦人。
知道可能是什么原因造成的吗? 要么是不必要的导入,要么是空行导入。
Eclipse: Indigo Service Release 1
Eclipse platform: 3.7.1
PyDev: 2.3.0.2011121518
Python: 3.2.2
非常感谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
自动导入通过所谓的“代码完成(ctx 不敏感)”来工作......这里主要问题似乎是您请求“len”的代码完成,并且它在许多其他地方定义(你最终会选择其中之一)。
所以,我认为在你的情况下,如果你通常对短名称进行补全,更好的方法可能是增加字符数来显示这些补全(默认情况下,当至少有 2 个字符可用时,它会带来这些补全)。
您可以在以下位置进行配置:
窗口 >偏好> pydev >编辑>代码完成(ctx 不敏感和常见标记)。
并将字符数更改为更高的数字(因为您可能请求用 2 个字符完成以获得 len,所以您可能希望将该请求放入 3 个或 4 个字符中)。
另一种可能的方法是将“len”放入“通用标记”列表中(在同一首选项页面中),因此,它会在您键入时完成,您只需要选择它,而无需实际操作要求完成。
至于您在关闭自动导入时报告的问题,我无法重现它(即:它没有添加任何空行),因此,如果您可以将其报告为错误中的错误,那就太好了PyDev 错误跟踪器具有更好的说明(即:源文件和重现步骤)。
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).
应该会出现一个弹出列表以及代码完成。向下滚动到
len(object)
选项。使用 Python 2.7,我无法重现您所描述的怪异现象。 Py3 可能有一些奇怪的行为。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.