> No, it has always been this way round. In fact test_order was inherited > from Guido's original version of test_decorators.py (from patch #926860) > where it read: > > def test_order(self): > class C(object): > [funcattrs(abc=1), staticmethod] > def foo(): return 42 > # This wouldn't work if staticmethod was called first > self.assertEqual(C.foo(), 42) > self.assertEqual(C().foo(), 42) > > (i.e. identical to the current version except for the change in > syntax). In fact I relied on the fact that this test passed to > convince me I had the order right! But I should have spotted the > inconsistency between that and the documentation that I wrote for > the reference manual. Oops. When using a list, it makes sense to apply the decorators left-to-right. But when using @deco, I think it makes more sense that the decorators closer to the def are applied first. IOW the syntax is conceptually right-recursive: definition ::= '@' decorator definition | 'def' ... > I'll do a patch to fix the order and the corresponding tests. Great. > While I'm at it, do we want to drop support for multiple decorators > on a single line? Nobody has spoken up for it, and in fact forcing > one-per-line would simplify the grammar (as well as making it easier > for toy parsers to find decorators). +1 --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4