[Tutor] real world decorators
John
jfabiani at yolo.com
Mon Sep 21 18:14:07 CEST 2009
On Sunday 20 September 2009 03:43:32 pm Eike Welk wrote:
> On Sunday 20 September 2009, John wrote:
> > Hi,
> >
> > I think I understand what decorators are and how they work. Maybe
> > it's just me but I don't know where I'd use them in my real world
> > programming. I see how they work with profile or coverage but does
> > anyone have real world uses.
>
> Frequently used are @classmethod and @staticmethod:
> http://docs.python.org/library/functions.html#classmethod
>
> An other interesting usage of decorators is Phillip J.
> Eby's 'simplegeneric' library, where decorated functions replace big
> if... elif... constructions:
> http://cheeseshop.python.org/pypi/simplegeneric/0.6
>
> But really decorators are just syntactical sugar. They are an elegant
> way to write a special case of a function call.
>
> Kind regards,
> Eike.
Thanks to all that responded on list and off. You guys have provided much to
read.
Thanks
Johnf
More information about the Tutor
mailing list