22 May
2012
22 May
'12
10:05 p.m.
Minor nit. On May 22, 2012, at 04:43 PM, PJ Eby wrote:
def declare_namespace(package_name): parent, dot, tail = package_name.rpartition('.') attr = '__path__' if dot: declare_namespace(parent) else: parent, attr = 'sys', 'path' with importlockcontext: module = sys.modules.get(package_name)
Best to use a marker object here instead of checking for None, since the latter is a valid value for an existing entry in sys.modules.
if module is None: module = XXX new module here module.__path__ = _NamespacePath(...stuff involving 'parent' and 'attr')
Cheers, -Barry