En Tue, 22 May 2007 04:21:06 -0300, tag <[EMAIL PROTECTED]> escribió:
> Here's a function which rebinds a function at the top level of a > module (it won't work for nested functions). > >>>> def announce_function(f): > ... " Rebind f within a module so that calls to f are announced. " > ... import inspect > ... setattr(inspect.getmodule(f), f.__name__, announce(f)) > > Let's give it a try. This next works fine in an interactive Python > session but fails when doctested. The version given by Peter Otten may do what you want, but I'd consider if you really need an announce_function in the first place, given all the other ways you already have to do the same thing. Implicitely rebinding globals does not look good. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list