Commit cf14c484 authored by Syrtis Major's avatar Syrtis Major Committed by GitHub

IPython magic only import things in `"__all__"`

Make the IPython cell magic only import things in `"__all__"` when `"__all__"` exits.
parent af4737d7
......@@ -93,7 +93,15 @@ class CythonMagics(Magics):
self._pyximport_installed = False
def _import_all(self, module):
for k,v in module.__dict__.items():
mdict = module.__dict__
if '__all__' in mdict:
for k in mdict['__all__']:
if k in mdict:
self.shell.push({k:mdict[k]})
else:
raise AttributeError("'module' object has no attribute '%s'" % k)
else:
for k, v in mdict.items():
if not k.startswith('__'):
self.shell.push({k:v})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment