Are decorators really that different from metaclasses...
Colin J. Williams
cjw at sympatico.ca
Fri Aug 27 09:17:50 EDT 2004
Paul Morrow wrote:
[snip]
>
>
> Yes, it doesn't seem all that complex, although I'm not sure that
> everyone reading this understands them and their subtleties. The
> following is an excerpt from
> http://docs.python.org/tut/node11.html#SECTION0011200000000000000000
>
> "A namespace is a mapping from names to objects. Most namespaces are
> currently implemented as Python dictionaries, but that's normally not
> noticeable in any way (except for performance), and it may change in the
> future. Examples of namespaces are: the set of built-in names (functions
> such as abs(), and built-in exception names); the global names in a
> module; and the local names in a function invocation. In a sense the set
> of attributes of an object also form a namespace."
>
> When I talk about namespaces, I include all of the above, including the
> sense mentioned in the last line. So an object's attributes constitute
> a namespace too. Therefore __doc__, being an attribute of the function
> object, is in the function object's /namespace/. And note that this is
> *not* a new namespace; it's been there all along.
>
Could you elaborate on the last sentence please? Is the namespace not
created when the def ... line(s) is/are executed?
Colin W.
More information about the Python-list
mailing list