[Tutor] Decorators

Michael ms at cerenity.org
Tue Apr 11 20:03:15 CEST 2006

On Tuesday 11 April 2006 17:43, Alan Gauld wrote:
> >> There is no practical use for decorators IMHO
> >
> > It's true that decorators are syntactic sugar and don't add any new
> > functional capabilities to the language.
> Which is all I intended to imply.

You have a different meaning of "practical use" from common usage then. 
Something that makes it easier to:
   * Understand that a function has been modified
   * Make it clear that a function is a staticmethod/classmethod/etc *right at
      the beginning of a function* without having to read the entire body.
   * Reduce typing
   * Allow hinting of types for integration with tools like PyObjC
   * Make it clear when reading the definition of a method/function is
      memoised, traced etc
   * Simplifying augmentation of generators with arbitrary extra
      communications attributes.

... are all practical benefits. That means they have practical use in my
book :-)

Syntactic sugar *IS* a practical benefit. After all, every language above 
assember is syntactic sugar, and by your definition of no practical use.


More information about the Tutor mailing list