Are decorators really that different from metaclasses...

Steven Bethard steven.bethard at gmail.com
Tue Aug 31 15:26:34 EDT 2004


Paul Morrow <pm_mon <at> yahoo.com> writes:
> The assignments to __xxx__ variables (immediately following the 
> docstring, if present) would occur in the namespace of the object 
> (function/method) being defined.  The assignments would not cause them 
> to change namespaces.


What you're suggesting is that given:

def f1():
    __author__ = 'Steve'

and

def f2():
    author = 'Steve'

in f1, the assignment to __author__ occurs in the function's namespace, but in 
f2, the assignment to author occurs in the local namespace.  Clearly then, the 
__xxx__ format (if at the beginning of a function) changes the namespace to 
which an assignment applies.  How is this not causing assignments to change 
namespaces?

Steve




More information about the Python-list mailing list