Bo Peng wrote:
Dear list,

If you ask: why do you choose these names? The answer is: they need to be conformable with other functions, parameter names.

I have a function that pretty much like:

def output(output=''):
  print output

and now in another function, I need to call output function, with again keyword parameter output

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?

Yes, but you probably don't want to go that way. Can you explicitly indicate the location of the 'output' function? e.g.:


py> def output(output=''):
...     print output
...
py> def func(output=''):
...     __import__(__name__).output(output)
...
py> func('abc')
abc

or possibly:

py> def func(output=''):
...     globals()['output'](output)
...
py> func('abc')
abc

This is easier if output is in another module -- you can just write something like:
outputmodule.output(output)


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

Reply via email to