Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.glorb.com!newsfeed.xs4all.nl!newsfeed5.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'callable.': 0.09; 'decorator': 0.09; 'restriction': 0.09; 'essentially': 0.11; 'syntax': 0.11; 'wrote:': 0.15; 'callable,': 0.16; 'doing:': 0.16; 'general.': 0.16; 'non-callable': 0.16; 'useful,': 0.16; 'cc:addr :python-list': 0.16; 'pm,': 0.16; 'cheers,': 0.19; 'language': 0.20; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In- Reply-To:1': 0.22; 'sat,': 0.28; 'message-id:@mail.gmail.com': 0.28; 'bound': 0.29; '"the': 0.29; 'cc:addr:python.org': 0.30; 'if,': 0.30; 'equivalent': 0.31; 'subject:?': 0.31; 'does': 0.32; "isn't": 0.35; 'probably': 0.35; 'skip:" 10': 0.36; 'idea': 0.36; 'but': 0.37; 'could': 0.37; 'received:google.com': 0.38; 'received:209.85.161': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'something': 0.38; 'two': 0.38; 'should': 0.39; 'received:209': 0.40; 'john': 0.62; 'subject:this': 0.74; 'subject:won': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=g7T25q9tXqez4jvVZQwTUFJnkw/kz1ZLrLSpz6F6Fn8=; b=NqYUAVDb/wxOh8raRSFBT7Rm+/r3U0APALes3W7WYLIrJFpcTVw37Owcvf/yFYIAUq BI/g0dI8OJ7qQeN5On9qpaOGtax7TC3eDWuiy0uIwvhP5CmtRAERQyw8lfpMrI5f7oqC 7uDGghjir2mt998Miz7xTOW479XBCn8Qla8iA= MIME-Version: 1.0 In-Reply-To: <98cca0c2-8d4f-4313-abed-3f34fa165c6d@u28g2000yqf.googlegroups.com> References: <8b8c3ca2-ae36-4009-842e-1dc90fb01b65@ct4g2000vbb.googlegroups.com> <98cca0c2-8d4f-4313-abed-3f34fa165c6d@u28g2000yqf.googlegroups.com> From: Ian Kelly Date: Sat, 2 Jul 2011 12:49:15 -0600 Subject: Re: Why won't this decorator work? To: John Salerno Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1309632586 news.xs4all.nl 21755 [2001:888:2000:d::a6]:38274 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8678 On Sat, Jul 2, 2011 at 12:08 PM, John Salerno wrote: > But why does the documentation say "The return value of the decorator > need not be callable"? Because the language does not enforce the restriction that the return value should be a callable. If it's not a callable, then the result will just be that something non-callable is bound to the "roll_die" name -- which could be useful, but is probably a bad idea in general. > And why, if I remove the decorator and just > leave the two functions as if, does the call to move(roll_die()) work? > Isn't that what the decorator syntax is essentially doing? No. The decorator syntax is doing: roll_die = move(roll_die) If you then call roll_die, that is equivalent to "move(roll_die)()", which is not the same thing as "move(roll_die())". Cheers, Ian