On Mon, Jul 9, 2018 at 3:55 AM, Eric V. Smith <e...@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 "<stdin>", line 1 > @lookup[0] > ^ > SyntaxError: invalid syntax > > But this works: > >>>> new_decorator = lookup[0] >>>> @new_decorator > ... 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 _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com