Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29175

Re: Decorators not worth the effort

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=5977eef39=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'decorator': 0.07; 'users,': 0.07; 'python': 0.09; 'does,': 0.09; 'sep': 0.09; 'def': 0.10; 'subject:not': 0.11; 'agree.': 0.16; 'email addr:functools.wraps(func)': 0.16; 'timeout):': 0.16; 'wrote:': 0.17; 'decorators': 0.22; 'effort.': 0.22; 'cc:2**0': 0.23; 'work.': 0.23; 'header:In-Reply-To:1': 0.25; 'realize': 0.27; 'email name:': 0.29; 'steven': 0.29; 'fri,': 0.30; 'function': 0.30; '-----': 0.32; 'not.': 0.32; '+0200,': 0.33; "aren't": 0.33; 'function.': 0.33; 'to:addr:python-list': 0.33; 'another': 0.33; 'returning': 0.35; 'something': 0.35; 'does': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'takes': 0.39; 'your': 0.60; 'easy': 0.60; 'received:194': 0.61; 'experts': 0.66; 'cook,': 0.84; 'drive.': 0.84; 'tie': 0.84
X-IronPort-AV E=Sophos;i="4.80,423,1344204000"; d="scan'208";a="726259"
X-Virus-Scanned amavisd-new at zimbra.sequans.com
Date Fri, 14 Sep 2012 17:35:57 +0200 (CEST)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To python-list@python.org
In-Reply-To <50534b1e$0$29981$c3e8da3$5496439d@news.astraweb.com>
Subject Re: Decorators not worth the effort
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Mailer Zimbra 7.2.0_GA_2669 (ZimbraWebClient - GC7 (Linux)/7.2.0_GA_2669)
Cc Steven D'Aprano <steve+comp.lang.python@pearwood.info>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.710.1347636980.27098.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1347636980 news.xs4all.nl 6897 [2001:888:2000:d::a6]:43038
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29175

Show key headers only | View raw


----- 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


Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Decorators not worth the effort Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-09-14 17:35 +0200

csiph-web