Kent Johnson wrote:
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

Thank everyone for the quick responses. All methods work in general. Since func() has to take the same parameter set as some other functins, I can not use func(output='', output_fn=output). "output_alias=output" etc are fine.


Bo
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to