Meta programming question

Alex Martelli aleax at aleax.it
Sun Sep 28 07:13:35 EDT 2003


Bruce Dickey wrote:

> I've read a number of the meta progamming articles. I have not found
> what I am looking for. I want to override assignments to variables which
> are in the module namespace (not object members -- no classes involved).
> Can this be done?

No (not without, as somebody already suggested, rewriting substantial
portions of Python's C-level implementation).  A module-level statement

    <name> = <expression>

evaluates the expression, and sets the name to refer to its value -- no
ifs, no buts, no overriding, and nothing to do with metaprogramming.


Alex





More information about the Python-list mailing list