A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-August/047519.html below:

[Python-Dev] Decorator order implemented backwards?

[Python-Dev] Decorator order implemented backwards? [Python-Dev] Decorator order implemented backwards?Anthony Baxter anthony at interlink.com.au
Tue Aug 10 07:00:27 CEST 2004
James Y Knight wrote:
> I haven't seen anyone remark upon this yet, but the order of decorator 
> application appears to be implemented backwards.
>>     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)

How odd. I'm positive at one point I tested this and it was
the right way round.

 >>> def dec1(x):
...     print "dec1"
...     return x
...
 >>> def dec2(x):
...     print "dec2"
...     return x
...
 >>>
 >>> @dec1
... @dec2
... def foo(): pass
...
dec1
dec2
 >>>

This is definitely wrong. Wrong wrong wrong.

Anthony
More information about the Python-Dev mailing list

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