Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #57946 > unrolled thread
| Started by | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| First post | 2013-10-29 12:54 -0500 |
| Last post | 2013-10-30 11:46 +1300 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| Date | 2013-10-29 12:54 -0500 |
| Subject | Re: stacked decorators and consolidating |
| Message-ID | <mailman.1769.1383069148.18130.python-list@python.org> |
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
[toc] | [next] | [standalone]
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| Date | 2013-10-30 11:46 +1300 |
| Message-ID | <bdas6gFl5t8U1@mid.individual.net> |
| In reply to | #57946 |
Tim Chase wrote: > I'd have figured they would be associative, making the result end up > the same either way, but apparently not. They're not associative because function application is not associative: f(g(x)) is not the same thing as f(g)(x). -- Greg
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web