[Python-Dev] Call for prudence about PEP-572 (original) (raw)

Chris Angelico rosuav at gmail.com
Sun Jul 8 13:59:10 EDT 2018


On Mon, Jul 9, 2018 at 3:55 AM, Eric V. Smith <eric at trueblade.com> wrote:

I agree with Chris in this case. That said, there is at least one place where the grammar does forbid you from doing something that would otherwise make be allowable: decorators.

@lookup[0] File "", line 1 @lookup[0] ^ SyntaxError: invalid syntax But this works: newdecorator = lookup[0] @newdecorator ... def f(): pass Thus, the idea of restricting the type of expression that can be used in particular circumstances is not without precedent, and should not be dismissed at face value. That is, unless we want to remove the restriction on decorators, which I'm okay with, too. I have occasionally wanted to do something more complicated with a decorator, and used the workaround above.

This is true. I wasn't around when decorator syntax was discussed; what were the reasons for this being the way it is? It isn't simply "'@' test".

ChrisA



More information about the Python-Dev mailing list