parameter name conflict. How to solve?

Kent Johnson kent37 at tds.net
Tue Mar 8 06:04:32 EST 2005


Bo Peng wrote:
> def func(output=''):
>   output(output=output)
> 
> Naturally, I get 'str' object is not callable. Is there a way to tell 
> func that the first output is actually a function? (like in C++, 
> ::output(output) )

You could use a default argument:
def func(output='', output_fn=output):
   output_fn(output=output)

Kent



More information about the Python-list mailing list