[Python-ideas] Multiple arguments for decorators

Chris Angelico rosuav at gmail.com
Mon Nov 30 21:58:37 EST 2015


On Tue, Dec 1, 2015 at 1:52 PM, Andrew Barnert <abarnert at yahoo.com> wrote:
> I think this is a bad idea from the start. Only functions and classes have scopes; normal suite do not. If you change that to add "... except the suite of a with statement whose context manager is a decorator", that's no longer a simple rule you can hold in your head.
>

And list comprehensions. They have a new nested scope, even though you
can't see the function call. Everywhere else that you see a 'for'
loop, it's exactly the same semantics as any other assignment - but if
it's inside square brackets, it's a special form of local name that
doesn't extend past the brackets. This would be the same - a hidden
function call that creates a nested scope.

ChrisA


More information about the Python-ideas mailing list