__getattr__ functionality for modules?
Aahz
aahz at pythoncraft.com
Sun May 18 20:58:48 EDT 2003
In article <k85gcvgdg7lgldmnrq88gqgmdmla9r0q5l at 4ax.com>,
Stefan Franke <franke at ableton.com> wrote:
>On 18 May 2003 18:55:20 -0400, aahz at pythoncraft.com (Aahz) wrote:
>>
>>Nope, and Guido is violently opposed to making this possible. Why not
>>just use a class?
>
>Because a namespace object behaves different when it comes to setting
>attributes: There are no nested scopes.
>
>What I'm trying to realize is a small domain specific configuration
>language: A subset of Python that consists of nothing else but
>
>- a couple of functions,
>
>- the ability to define your own functions with 'def' with correct scope nesting
>
>- Python's numeric expressions
>
>- and an (unlimited) number of builtin constants. That's what I need
> the module getattr hook for
>
>This is absolutely trivial to learn for the users in my context. Using
>objects and attributes here adds an unnecessary (and unwanted)
>level of complexity.
But you can import their module and attach the functions to a class
object. They don't need to know that. ;-)
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"In many ways, it's a dull language, borrowing solid old concepts from
many other languages & styles: boring syntax, unsurprising semantics,
few automatic coercions, etc etc. But that's one of the things I like
about it." --Tim Peters on Python, 16 Sep 93
More information about the Python-list
mailing list