Strange module auto complete behavior in IPython

强颜欢笑 提交于 2020-01-17 08:34:13

问题


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)


回答1:


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.

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.

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.



来源:https://stackoverflow.com/questions/16998369/strange-module-auto-complete-behavior-in-ipython

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!