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


Groups > comp.lang.python > #8677

Re: Why won't this decorator work?

Date 2011-07-02 13:45 -0500
From Tim Chase <python.list@tim.thechases.com>
Subject Re: Why won't this decorator work?
References <8b8c3ca2-ae36-4009-842e-1dc90fb01b65@ct4g2000vbb.googlegroups.com> <mailman.561.1309628013.1164.python-list@python.org> <98cca0c2-8d4f-4313-abed-3f34fa165c6d@u28g2000yqf.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.562.1309632366.1164.python-list@python.org> (permalink)

Show all headers | View raw


On 07/02/2011 01:08 PM, John Salerno wrote:
> On Jul 2, 12:33 pm, MRAB<pyt...@mrabarnett.plus.com>  wrote:
>>       roll_die = move(roll_die)
>>
>> You should be defining a function (a callable) and then passing it to a
>> decorator which returns a callable.
>
> But why does the documentation say "The return value of the decorator
> need not be callable"?

I must not be looking at the same documentation you are...could 
you provide a link? The only time I know of that the return value 
of a decorator need not be callable is if you want to totally 
break the syntax of the function. :-/

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

Are you doing

   move(roll_die()) #call roll_die() and pass results to move()

or

   move(roll_die) # pass the function-object roll_die to move()

?  The decorator syntax is the equivalent of

   roll_die = move(roll_die)

-tkc


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


Thread

Why won't this decorator work? John Salerno <johnjsal@gmail.com> - 2011-07-02 09:56 -0700
  Re: Why won't this decorator work? MRAB <python@mrabarnett.plus.com> - 2011-07-02 18:33 +0100
    Re: Why won't this decorator work? John Salerno <johnjsal@gmail.com> - 2011-07-02 11:08 -0700
      Re: Why won't this decorator work? Tim Chase <python.list@tim.thechases.com> - 2011-07-02 13:45 -0500
        Re: Why won't this decorator work? John Salerno <johnjsal@gmail.com> - 2011-07-02 13:39 -0700
          Re: Why won't this decorator work? Ben Finney <ben+python@benfinney.id.au> - 2011-07-03 08:36 +1000
          Re: Why won't this decorator work? "OKB (not okblacke)" <brenNOSPAMbarn@NObrenSPAMbarn.net> - 2011-07-03 18:01 +0000
            Re: Why won't this decorator work? John Salerno <johnjsal@gmail.com> - 2011-07-03 20:24 -0700
            Re: Why won't this decorator work? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-07-04 20:22 +1200
      Re: Why won't this decorator work? Ian Kelly <ian.g.kelly@gmail.com> - 2011-07-02 12:49 -0600
        Re: Why won't this decorator work? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-07-03 16:14 +1200
      Re: Why won't this decorator work? ChasBrown <cbrown@cbrownsystems.com> - 2011-07-02 12:16 -0700
      Re: Why won't this decorator work? ChasBrown <cbrown@cbrownsystems.com> - 2011-07-02 12:17 -0700
      Re: Why won't this decorator work? ChasBrown <cbrown@cbrownsystems.com> - 2011-07-02 12:16 -0700
      Re: Why won't this decorator work? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-03 12:11 +1000
        Re: Why won't this decorator work? John Salerno <johnjsal@gmail.com> - 2011-07-02 19:14 -0700

csiph-web