[Python-Dev] PEP 343: Context managers a superset of decorators?

Josiah Carlson jcarlson at uci.edu
Mon Feb 13 03:24:18 CET 2006


Eric Sumner <kd5bjo at gmail.com> wrote:
> Forgive me if someone has already come up with this; I know I am
> coming to the party several months late.  All of the proposals for
> decorators (including the accepted one) seemed a bit kludgey to me,
> and I couldn't figure out why.  When I read PEP 343, I realized that
> they all provide a solution for an edge case without addressing the
> larger problem.

[snip code samples]

> I will readily admit that I have no idea how difficult either of these
> suggestions would be to implement, or if it would be a good idea to do
> so.  At this point, they are just something to think about

Re-read the decorator PEP: http://www.python.org/peps/pep-0318.html to
understand why both of these options (indentation and prefix notation)
are undesireable for a general decorator syntax.

The desire for context managers to have access to its enclosing scope is
another discussion entirely, though it may do so without express
permission via stack frame manipulation.

 - Josiah



More information about the Python-Dev mailing list