Name of function caller

James Stroud jstroud at mbi.ucla.edu
Tue May 15 19:48:30 EDT 2007


HMS Surprise wrote:
> Is there a way that a function may access the doc string or func_name
> of the caller?
> 
> Thanks,
> 
> jvh
> 

Add a parameter to the function to avoid mutilating your code with 
implementation specific inspection:

def fun(caller, *original_parameters):
   do_something_to_caller_without_magic(caller)
   do_something_with_original_parameters(*original_parameters)

James



More information about the Python-list mailing list