[Python-Dev] PEP 318 trial balloon (wrappers)

Phillip J. Eby pje at telecommunity.com
Fri Mar 12 10:03:36 EST 2004


At 06:50 PM 3/11/04 -0500, Jewett, Jim J wrote:
>----------
>class Foo:
>     [transform] from:
>         def x():
>             pass
>
>[wrapper] from:
>     class x:
>         pass
>
>[decorator] from:
>     def x():
>         pass
>
>x() is now defined exactly as it was before,
>except that it has an extra indent to the right.
>
>---------
>
>I understand most of the objections well enough to
>summarize them; I'm singling these out because I'm
>not sure I that I do.
>
>Phillip J. Eby:
>
> > It is ambiguous precisely *because* it introduces a new suite.
> > Suites in Python indicate a difference in execution context,
> > often along with introducing a new namespace.  This new syntax
> > does neither.
>
>Today, if we wait until the declaration is finished, we can write
>
>     for decorator in seq:
>         var = decorator(var)
>
>How does this construct change the context or namespace any less
>than a for loop?

In your proposal, the function definition is nested, but its execution 
context and namespace are unchanged.  The presence of a suite implies that 
either the control flow or the namespace (or both) are affected, but your 
proposed syntax affects neither.




More information about the Python-Dev mailing list