A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-January/032132.html below:

[Python-Dev] properties on modules?

[Python-Dev] properties on modules? [Python-Dev] properties on modules?Guido van Rossum guido@python.org
Mon, 13 Jan 2003 15:48:13 -0500
> The Quixote web system publishes Python functions by traversing name
> spaces.  The publishing code is very roughly:
> 
>     def get_object(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 = root_namespace
>         for component in '/'.split(path[1:]):
>             o = get_object(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/)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4