Decorators not worth the effort

Jean-Michel Pichavant jeanmichel at sequans.com
Fri Sep 14 11:35:57 EDT 2012


----- Original Message -----
> On Fri, 14 Sep 2012 15:22:26 +0200, Jean-Michel Pichavant wrote:
> 
> > Here's Steven example:
> > 
> > # Untested!
> > def timeout(t=15):
> >     # Decorator factory. Return a decorator to actually do the
> >     work. if
> >     FPGA:
> >         t *= 3
> >     def decorator(func):
> >         @functools.wraps(func)
> >         def inner(self, timeout):
> >             self.sendCmd("bootMe", timeout=t)
> >         return inner
> >     return decorator
> > 
> > I can assure you, that for some python users, it's is not easy to
> > understand what it does, this function returning a function which
> > returns another (wrapped) function. It requires some effort.
> 
> Oh I agree. So does learning to tie your shoe-laces, learning to
> cook,
> and learning to drive.
> 
> Learning to be a world-class chess master takes a lot of effort.
> Learning
> about decorators does not.
> 
> 
> --
> Steven

I said some effort, not a lot of effort. Something else that requires some effort it to make experts realize that some things they consider trivial and easy, aren't actually for a lot of people. 
Returning to my cave.

JM






More information about the Python-list mailing list