Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide imported modules to interpreter

Tags:

python

ipython

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?

like image 721
Jimmy C Avatar asked Oct 29 '13 16:10

Jimmy C


1 Answers

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
like image 151
minrk Avatar answered Oct 31 '22 18:10

minrk