[Python-Dev] PEP 420 - dynamic path computation is missing rationale (original) (raw)
Barry Warsaw barry at python.org
Wed May 23 00:05:32 CEST 2012
- Previous message: [Python-Dev] PEP 420 - dynamic path computation is missing rationale
- Next message: [Python-Dev] PEP 420 - dynamic path computation is missing rationale
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Minor nit.
On May 22, 2012, at 04:43 PM, PJ Eby wrote:
def declarenamespace(packagename): parent, dot, tail = packagename.rpartition('.') attr = 'path' if dot: declarenamespace(parent) else: parent, attr = 'sys', 'path' with importlockcontext: module = sys.modules.get(packagename)
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
- Previous message: [Python-Dev] PEP 420 - dynamic path computation is missing rationale
- Next message: [Python-Dev] PEP 420 - dynamic path computation is missing rationale
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]