On Tue, Aug 10, 2010 at 8:22 PM, Steve Holden <steve at holdenweb.com> wrote: > One of the things that's slightly irking about the decorator syntax is > that a decorator is always called with exactly one argument, and that if > you want to write a parameterized decorator you therefore end up writing > a function that returns a function that returns a function. > > I've scratched my head about how partials (or indeed anything else) > could be used to make the extra level of indirection necessary, but > haven' come up with anything that even I could regard as acceptable. But > I can't escape this feeling that there must be a way. Someone at EuroPython brought up this very criticism. But my argument against it is: you should be able to write either @bar(args) def func(): ... or foo = bar(args) @foo def func(): ... and you should be able to predict how these two relate using standard knowledge about what it means to say foo = bar(args) and then use foo in an expression. That pretty much rules out solutions using partial IMO. (Not that I mind -- I find examples using partial as hard to read as code using reduce()... :-) -- --Guido van Rossum (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