Hi, # If I have a function definition def f1(arg): global capturecall if capturecall: ... do_normal_stuff(arg)
# and its later use: def f2(): ... return f1(a and (b or c)) # I would like to do: capturecall = False result = f2() # And get the equivalent of do_normal_stuff(a and(b or c)) # But also to do: capturecall = True result = f2() # And get the same result, but also save the actual # calling arguments to f1 either as a string: # "a and (b or c))" # Or a code object computing a and(b or c) # I caould change f1 to expect a function instead and do: def f1b(arg): global capturecall if capturecall: save(arg) return do_normal_stuff(arg()) # And then use it like this: def f2b(): ... return f1b(lambda : (a and (b or c)) ) # The problem is that for my application to work, # Python newbies would have to write lambda when they # know they are after the result. Its my program # that would require the lambda (or def), which # is a distraction from their problem. Any ideas on implementing f1 so I can do f2? Thanks in advance, Paddy. P.S. You might also have multiple calls where I would need to capture each individual argument expression of f1 e.g: def f3(): ... return f1(a and b) or e or f1(c and d) -- http://mail.python.org/mailman/listinfo/python-list