I have built a module which is using a few different modules for various tasks. When I'm importing my module in IPython and listing the available functions for autocompletion, these external modules are included in that list. Is it possible to hide them in some way?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
In Python, modules can define an __all__
variable, which is a list of the names that should be imported when someone does:
from module import *
IPython can use the same variable to limit completions, though it does not do this by default. To enable this at runtime, set:
get_ipython().Completer.limit_to__all__ = True
Or to set it permanently, add to your ipython_config.py
:
c.IPCompleter.limit_to__all__ = True