On 11Oct2013 02:37, Gilles Lenfant wrote:
> * Adding an "__original__" attribute to the wrapper func in the decorators of
> my own
Just one remark: Call this __original or _original (or even original).
The __x__ names are reserved for python operations (like __add__, supporting
"+").
Cheers,
-
On 10/10/13 10:22 PM, Cameron Simpson wrote:
On 10Oct2013 19:44, Ned Batchelder wrote:
On 10/10/13 6:12 PM, Cameron Simpson wrote:
Speaking for myself, I would be include to recast this code:
@absolutize
def addition(a, b):
return a + b
into:
def _addition(a, b):
retu
On 10/10/2013 08:13 PM, Cameron Simpson wrote:
On 11Oct2013 02:55, Steven D'Aprano
wrote:
On Fri, 11 Oct 2013 09:12:38 +1100, Cameron Simpson wrote:
Speaking for myself, I would be include to recast this code:
@absolutize
def addition(a, b):
return a + b
into:
def _addition
On 10/10/2013 08:01 PM, Roy Smith wrote:
On 10Oct2013 19:44, Ned Batchelder wrote:
I have to admit I'm having a hard time understanding why you'd need
to test the undecorated functions. After all, the undecorated
functions aren't available to anyone. All that matters is how they
behave with t
Cameron, Steven, Ben, Ned, Terry, Roy. Many thanks for this interesting
discussion.
I ended up... mixing some solutions provided by your hints :
* Adding an "__original__" attribute to the wrapper func in the decorators of
my own
* Playing with "func_closure" to test functions/methods provided
On 10/11/2013 4:17 AM, Terry Reedy wrote:
On 10/10/2013 11:13 PM, Cameron Simpson wrote:
On 11Oct2013 02:55, Steven D'Aprano
wrote:
def undecorate(f):
"""Return the undecorated inner function from function f."""
return f.func_closure[0].cell_contents
Whereas this feels like black
On 10/11/2013 4:17 AM, Terry Reedy wrote:
On 10/10/2013 11:13 PM, Cameron Simpson wrote:
On 11Oct2013 02:55, Steven D'Aprano
wrote:
def undecorate(f):
"""Return the undecorated inner function from function f."""
return f.func_closure[0].cell_contents
Whereas this feels like black
On 10/11/2013 12:36 AM, Steven D'Aprano wrote:
I also like Terry Reedy's suggestion of having the decorator
automatically add the unwrapped function to the wrapped function as an
attribute:
def decorate(func):
@functools.wraps(func)
def inner(arg):
blah blah
inner._unwra
On 10/10/2013 11:13 PM, Cameron Simpson wrote:
On 11Oct2013 02:55, Steven D'Aprano
wrote:
def undecorate(f):
"""Return the undecorated inner function from function f."""
return f.func_closure[0].cell_contents
Whereas this feels like black magic. Is this portable to any decorated
On 11Oct2013 05:51, Steven D'Aprano
wrote:
> On Fri, 11 Oct 2013 15:36:29 +1100, Cameron Simpson wrote:
> > But is it reliable? Will it work on any decorated function?
>
> *Any* decorated function? No, of course not, since decorators can do
> anything they like: [... examples ...]
That was wha
On Fri, 11 Oct 2013 15:36:29 +1100, Cameron Simpson wrote:
> But is it reliable? Will it work on any decorated function?
*Any* decorated function? No, of course not, since decorators can do
anything they like:
def decorate(func):
return lambda *args: "Surprise!"
@decorate
def something_use
On Fri, 11 Oct 2013 14:13:19 +1100, Cameron Simpson wrote:
> On 11Oct2013 02:55, Steven D'Aprano
> wrote:
>> On Fri, 11 Oct 2013 09:12:38 +1100, Cameron Simpson wrote:
>> > Speaking for myself, I would be include to recast this code:
>> >
>> > @absolutize
>> > def addition(a, b):
>> >
On 11Oct2013 14:42, Ben Finney wrote:
> Cameron Simpson writes:
> > On 11Oct2013 02:55, Steven D'Aprano
> > wrote:
> > > def undecorate(f):
> > > """Return the undecorated inner function from function f."""
> > > return f.func_closure[0].cell_contents
> >
> > Whereas this feels like bla
Cameron Simpson writes:
> On 11Oct2013 02:55, Steven D'Aprano
> wrote:
> > def undecorate(f):
> > """Return the undecorated inner function from function f."""
> > return f.func_closure[0].cell_contents
>
> Whereas this feels like black magic. Is this portable to any decorated
> function
On 11Oct2013 02:55, Steven D'Aprano
wrote:
> On Fri, 11 Oct 2013 09:12:38 +1100, Cameron Simpson wrote:
> > Speaking for myself, I would be include to recast this code:
> >
> > @absolutize
> > def addition(a, b):
> > return a + b
> >
> > into:
> >
> > def _addition(a, b):
> >
On 10Oct2013 19:44, Ned Batchelder wrote:
> > I have to admit I'm having a hard time understanding why you'd need
> > to test the undecorated functions. After all, the undecorated
> > functions aren't available to anyone. All that matters is how they
> > behave with the decorators.
In article ,
On Fri, 11 Oct 2013 09:12:38 +1100, Cameron Simpson wrote:
> On 10Oct2013 07:00, Gilles Lenfant wrote:
>> (explaining the title) : my app has functions and methods (and maybe
>> classes in the future) that are decorated by decorators provided by the
>> standard library or 3rd party packages.
>>
On 10Oct2013 19:44, Ned Batchelder wrote:
> On 10/10/13 6:12 PM, Cameron Simpson wrote:
> >Speaking for myself, I would be include to recast this code:
> >
> > @absolutize
> > def addition(a, b):
> > return a + b
> >
> >into:
> >
> > def _addition(a, b):
> > return a + b
> >
> >
On 10/10/2013 10:00 AM, Gilles Lenfant wrote:
To add to the other two responses so far...
(explaining the title) : my app has functions and methods (and maybe classes in
the future) that are decorated by decorators provided by the standard library
or 3rd party packages.
But I need to test "u
On 10/10/13 6:12 PM, Cameron Simpson wrote:
On 10Oct2013 07:00, Gilles Lenfant wrote:
(explaining the title) : my app has functions and methods (and
maybe classes in the future) that are decorated by decorators
provided by the standard library or 3rd party packages.
But I need to test "undecor
On 10Oct2013 07:00, Gilles Lenfant wrote:
> (explaining the title) : my app has functions and methods (and
> maybe classes in the future) that are decorated by decorators
> provided by the standard library or 3rd party packages.
>
> But I need to test "undecorated" functions and methods in my uni
Hi,
(explaining the title) : my app has functions and methods (and maybe classes in
the future) that are decorated by decorators provided by the standard library
or 3rd party packages.
But I need to test "undecorated" functions and methods in my unit tests,
preferably without adding "special s
22 matches
Mail list logo