Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #57946
| Date | 2013-10-29 12:54 -0500 |
|---|---|
| From | Tim Chase <python.list@tim.thechases.com> |
| Subject | Re: stacked decorators and consolidating |
| References | <20131029115427.537e1bcd@bigbox.christie.dr> <526FF395.9040306@mrabarnett.plus.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1769.1383069148.18130.python-list@python.org> (permalink) |
On 2013-10-29 17:42, MRAB wrote: > If you apply the stacked decorators you get: > > myfun = dec1(args1)(dec2(args2)(dec3(args3)(myfun))) > > If you apply dec_all you get: > > myfun = dec1(args1)(dec2(args2)(dec3(args3)))(myfun) > > See the difference? You need the lambda to fix that. In this case, they happen to be CherryPy decorators: @cherrypy.expose() @cherrypy.tools.json_in() @cherrypy.tools.json_out() def myfunc(...): pass I'd have figured they would be associative, making the result end up the same either way, but apparently not. Thanks for helping shed some light on the subtle difference. -tkc
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: stacked decorators and consolidating Tim Chase <python.list@tim.thechases.com> - 2013-10-29 12:54 -0500 Re: stacked decorators and consolidating Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-10-30 11:46 +1300
csiph-web