function wrappers
Ramon Crehuet
rcsqtc at iiqab.csic.es
Wed Oct 10 06:39:24 EDT 2007
Dear all,
I have a Fortran programming background and I have some difficulties in
understading how function wrappers work. I have delved into the subject
because of the new decorators, but I understand the decorator syntax. My
ignorance is more profound... Here is an example without decorators:
def require_int(func):
def wrapper(arg):
assert isinstance(arg, int)
return func(arg)
return wrapper
p1(a):
print a
p2=require_int(p1)
My question is: why do p2 arguments become wrapper arguments? What is
the flux of the arguments in the program when you pass functions as
arguments?
I have looked into some books and google but I cannot find a
satisfactory explanation. Could somebody please give me a hint or point
me to an appropriate source?
Thanks for your time,
Ramon
More information about the Python-list
mailing list