On 06/07/16 20:35, bruce wrote:

> Saw the decorator thread earlier.. didn't want to pollute it. I know, I
> could google!
> 
> But, what are decorators, why are decorators? who decided you needed them!

decorators are things that modify functions in standard ways.
Specifically they are functions that act on functions.
Mostly people think of them as being the thing that comes after an @
sign, but in fact they are just functions but with a bit of syntactic
sugar to make them more readable.

You don't really *need* them as a feature, but if you have
the ability to treat functions as values they are a useful
technique.

Most Python programmers don't implement decorators they just
use the standard ones. But as the thread showed implementing
them is not too difficult once you get happy with the idea
of passing functions around as arguments to other functions.

As to who suggested them you'd need to go back through the
PEPs to see who first suggested it, and then maybe more to see
who's idea finally got accepted. I think it was in Python 2.5.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to