<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jan 20, 2015 at 8:28 AM, Chris Barker <span dir="ltr"><<a href="mailto:chris.barker@noaa.gov" target="_blank">chris.barker@noaa.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Mon, Jan 19, 2015 at 8:42 PM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Mon, Jan 19, 2015 at 5:04 PM, Chris Barker - NOAA Federal <span dir="ltr"><<a href="mailto:chris.barker@noaa.gov" target="_blank">chris.barker@noaa.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span></span>I always teach that the @ syntax is a decoration, not a decorator, whereas a decorator is a function that takes a function and returns another function ( usually a customized version of the passed in function). This distinction between decorators and decoration syntax keeps the door open to do just about anything with decorations, but am I the only one that thinks it's a bad idea to have it be for "any old thing we want to hang off a function"?<br clear="all"></blockquote><div><br></div></span><div>I think you're the only one who makes this distinction.</div></div></div></div></blockquote><div><br></div></span><div><span style="font-size:13px">No, I'm not -- take a look at any number of tutorial sites, and answers for newbies on SO, etc. I used to teach decorators without making the distinction, and got a lot of confused students. maybe the distinction is only useful for pedagogical purposes, but I introduced it here 'cause it's a bit harder to talk about when a "decorator" can be either a function the behaves a certain way or the @something line in the code.</span><br></div></div></div></div></blockquote><div><br></div><div>It's a fair cop.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> In common use "decorator" is used to describe both the syntax and the function invoked by the syntax. "Decoration" is never (well, very rarely) used. And calling any function that takes a function and returns one a decorator feels overreaching -- I'd only call it a decorator if it is intended to use with the decorator syntax.<br></div></div></div></div></blockquote><div><br></div></span><div>sure -- I'm having a hard time coming up with the word s to describe what I"m talking about as  "proper" decorator. The truth is, you can put any callable that takes at least one argument after that @. And I'm not suggesting that python should enforce anything in particular about that. What I am suggesting is that we should not officially suggest that you should use a decorator for any old thing that doesn't fit the usual sprit of decorators.</div></div></div></div></blockquote><div><br></div><div>Agreed. The 99% case is that a decorator returns a function that (with some qualifications) calls the decorated function.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>A decorator that simply adds stuff to the docstring feels pretty ugly to me, particular if it goes beyond docs to specifying something important about the typing, etc.</div></div></div></div></blockquote><div><br></div><div>This sounds totally fine to me, honestly.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><div>Hard to draw a line there, but I  think we should keep the spirit of decorators in mind.</div><div><br></div><div>But enough said.</div></div></div></div></blockquote><div><br></div><div>Amen.<br> <br></div></div>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)</div>
</div></div>