Re: How to peek inside a decorated function

2009-02-15 Thread Duncan Booth
Steven D'Aprano wrote: > > The reason I ask is because I've just spent the weekend battling with > doctests of decorated functions, and discovering that without > functools.wraps() all my doctests weren't being called. I'm wondering > whether it would be a good idea for doctest to auto-detect tes

Re: How to peek inside a decorated function

2009-02-15 Thread Peter Otten
Steven D'Aprano wrote: > Suppose I have a function f() which I know has been decorated, but I don't > have access to the original undecorated function any longer: > > def reverse(func): > def f(*args): > args = list(args) > args.reverse() > return func(*args) > ret

Re: How to peek inside a decorated function

2009-02-15 Thread Steven D'Aprano
Hrvoje Niksic wrote: >> Is there any way to peek inside the decorated function rsay() to get >> access to the undecorated function say()? > > This works in Python 2.5.2: > rsay.func_closure[0].cell_contents > Thanks to everyone who responded. The reason I ask is because I've just spent

Re: How to peek inside a decorated function

2009-02-15 Thread Aaron Brady
On Feb 15, 4:27 am, Hrvoje Niksic wrote: > Steven D'Aprano writes: > > Suppose I have a function f() which I know has been decorated, but I don't > > have access to the original undecorated function any longer: > > > def reverse(func): > >     def f(*args): > >         args = list(args) > >      

Re: How to peek inside a decorated function

2009-02-15 Thread Hrvoje Niksic
Steven D'Aprano writes: > Suppose I have a function f() which I know has been decorated, but I don't > have access to the original undecorated function any longer: > > def reverse(func): > def f(*args): > args = list(args) > args.reverse() > return func(*args) > re

Re: How to peek inside a decorated function

2009-02-15 Thread Peter Otten
Steven D'Aprano wrote: > Suppose I have a function f() which I know has been decorated, but I don't > have access to the original undecorated function any longer: > > def reverse(func): > def f(*args): > args = list(args) > args.reverse() > return func(*args) > ret

Re: How to peek inside a decorated function

2009-02-15 Thread Terry Reedy
Steven D'Aprano wrote: Suppose I have a function f() which I know has been decorated, but I don't have access to the original undecorated function any longer: def reverse(func): def f(*args): args = list(args) args.reverse() return func(*args) return f def say(*a

How to peek inside a decorated function

2009-02-14 Thread Steven D'Aprano
Suppose I have a function f() which I know has been decorated, but I don't have access to the original undecorated function any longer: def reverse(func): def f(*args): args = list(args) args.reverse() return func(*args) return f def say(*args): print args rsa