IPython中奇怪的模块自动完成行为 [英] Strange module auto complete behavior in IPython

查看:144
本文介绍了IPython中奇怪的模块自动完成行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


看看我的意思?起初它只显示 RB absolute_import 作为选项。我仍然可以导入 Gtk 。之后,它显示了几个选项。仍然不是完整的模块列表。如果我导入一些其他模块(我从文档中知道),那么它会出现在列表中。

See what I mean? At first it showed only RB and absolute_import as choices. STILL I was able to import Gtk. After that it showed a couple of more options. Still isn't a complete list of modules. If I import some other module (which I know of from the docs), then it appears in the list.

(我之前发布了类似的问题,但我不是能够很好地解释它,所以我再次发布它有更好的细节)

(I posted a similar problem previously but I wasn't able to explain it sufficiently well so I'm posting it again with better details)

推荐答案

自动完成试试确定你所要求的可能价值。 gi.repository可能在导入时定义了东西,因此在实际导入之前你无法完成所有操作。

Autocompletion try to determine the possible value of what you ask. gi.repository is probably defining stuff at import time so you cannot get everything right before actually importing it.

就像你覆盖了对象的 __ getattr __ 方法一样,你可以让它响应任意数量的密钥无法列出它们。

Like if you overwrote the __getattr__ method of an object, you could make it respond to an arbitrary amount of key without being able to list them.

要知道你应该深入研究 gi.repository (PyGI本身似乎已被弃用3年,由pygobject取代),从快速阅读中得到的是GObject的完全动态绑定,它真正构建于通过检查Gobject来导入时间。

To know the exact reason you should dive into the code of gi.repository (PyGI itself seem deprecated for 3 Years, replaced by pygobject), which from a quick readthrough is a completly dynamic binding of GObject that really build itself at import time by inspecting Gobject.

所以我很惊讶这样的模块在制表完成时有奇怪的行为。

So I wouldn't be surprise that such an module have weird behavior at tab-completion.

这篇关于IPython中奇怪的模块自动完成行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆