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


Groups > comp.lang.python > #98868

Re: What is wrong this wrapper (decorator)?

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Gregory Ewing <greg.ewing@canterbury.ac.nz>
Newsgroups comp.lang.python
Subject Re: What is wrong this wrapper (decorator)?
Date Mon, 16 Nov 2015 19:30:54 +1300
Lines 21
Message-ID <datbh0F80u3U1@mid.individual.net> (permalink)
References <dafb679e-c94c-47d2-9209-ce2a86a673d6@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net UvkGRmydngj4kpE/bdQ5aAaCXpPNE0yytRUio3JFfhko3+PTUb
Cancel-Lock sha1:2TV+dic010VoNQXC4k+eMrMuYGc=
User-Agent Mozilla Thunderbird 1.0.5 (Macintosh/20050711)
X-Accept-Language en-us, en
In-Reply-To <dafb679e-c94c-47d2-9209-ce2a86a673d6@googlegroups.com>
Xref csiph.com comp.lang.python:98868

Show key headers only | View raw


fl wrote:
> wrapper(sub(two, one))
> Out[38]: <function checker>

This doesn't do what you probably meant it to do.
It first calls sub() with arguments one and two, and
then passes the result of that (a Coordinate, if
sub is working properly) to wrapper(). Since
wrapper() expects a function, not a Coordinate,
that won't do anything useful.

What you probably meant to do is:

wrapper(sub)(one, two)

This passes the function sub to wrapper, which
returns another function; that function is then
called with arguments one and two.

-- 
Greg

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


Thread

What is wrong this wrapper (decorator)? fl <rxjwg98@gmail.com> - 2015-11-14 09:23 -0800
  Re: What is wrong this wrapper (decorator)? fl <rxjwg98@gmail.com> - 2015-11-14 09:29 -0800
  Re: What is wrong this wrapper (decorator)? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-11-16 19:30 +1300

csiph-web