Commit 64801957 authored by syrte's avatar syrte

import_all: skip single underscore

skip single underscore
minor restructure
parent a2a6cccf
......@@ -95,15 +95,16 @@ class CythonMagics(Magics):
def _import_all(self, module):
mdict = module.__dict__
if '__all__' in mdict:
for k in mdict['__all__']:
if k in mdict:
self.shell.push({k:mdict[k]})
keys = mdict['__all__']
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})
keys = [k for k in mdict if not k.startswith('_')]
for k in keys:
try:
self.shell.push({k: mdict[k]})
except KeyError:
msg = "'module' object has no attribute '%s'" % k
raise AttributeError(msg)
@cell_magic
def cython_inline(self, line, cell):
......
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