[Python-Dev] properties on modules? (original) (raw)
Guido van Rossum guido@python.org
Mon, 13 Jan 2003 15:48:13 -0500
- Previous message: [Python-Dev] properties on modules?
- Next message: [Python-Dev] properties on modules?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The Quixote web system publishes Python functions by traversing name spaces. The publishing code is very roughly:
def getobject(container, name): if hasattr(container, name): return getattr(container, name) elif isinstance(container, ModuleType): mname = container.name + '.' + name import(mname) return sys.modules[mname] else: raise TraversalError def publish(path): o = rootnamespace for component in '/'.split(path[1:]): o = getobject(o, component) return o() If you use instances for name spaces then you can use getattr or properties to lazily create attributes. It's annoying that there is nothing like getattr/setattr or properties for modules.
I still don't see the use case for late binding of module attributes.
--Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] properties on modules?
- Next message: [Python-Dev] properties on modules?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]