Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'suppose': 0.07; 'latter': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'useless': 0.09; 'def': 0.12; 'jan': 0.12; 'components.': 0.16; 'fine.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'decorators': 0.24; 'define': 0.26; 'equivalent': 0.26; '(for': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'external': 0.29; 'am,': 0.29; 'easier': 0.31; "i'd": 0.34; 'could': 0.34; 'there': 0.35; 'should': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'easy': 0.60; 'you.': 0.62; 'times': 0.62; 'making': 0.63; 'such': 0.63; 'become': 0.64; 'here': 0.66; 'discussion)': 0.84; 'dozens': 0.84; 'received:fios.verizon.net': 0.84; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Decorators Date: Sat, 15 Nov 2014 15:28:41 -0500 References: <96c138e4-ab95-4e5f-a0c8-e696b5a926bb@googlegroups.com> <8761ehmnnt.fsf_-_@elektro.pacujo.net> <26dba8fd-e403-4129-ad57-11376eb807bd@googlegroups.com> <87k32wk355.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-108-16-203-145.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <87k32wk355.fsf@elektro.pacujo.net> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416083347 news.xs4all.nl 2842 [2001:888:2000:d::a6]:49324 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80839 On 11/15/2014 8:24 AM, Marko Rauhamaa wrote: > I'd take top-posting if I were enlightened about how decorators could be > valuable. Here is part of the original rationale. @deco(arg) def f: suite is (for this discussion) equivalent to def f: suite f = deco(arg)(f) The latter requires writing 'f' 3 times instead of 1. Now suppose to meet external requirements, such as interfacing to Objective C, you had to wrap dozens of functions, each with long names, up to 30 chars, with multiple components. You would then become enlightened. Once the idea of making function wrapping easier emerged, many other applications emerged. Various stdlib modules define decorators. If you do not need to wrap functions, easy wrapping might seem useless to you. That's fine. You know they are there should you ever have need. -- Terry Jan Reedy