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) )
output_alias = output
def func (output=''):
output_alias(output=output)
Daniel
Bo Peng a écrit :
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,
Delaney, Timothy C (Timothy) wrote:
Is this a style guide thing?
Why not just:
def func(output_param=''):
output(output=output_param)
This is exactly the problem. There are a bunch of other functions that
use output='' parameter. Changing parameter name for this single
function may cause
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='',
Bo Peng wrote:
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.
One suggestion that I haven't seen so far:
Where
Bo Peng wrote:
def func(output=''):
output(output=output)
Another solution that hasn't been mentioned yet:
def func(**kwds):
output(output = kwds['output'])
You might want to do some more checking on the
contents of kwds to make sure it doesn't
contain any other nonsense parameters.
--
Bo Peng wrote:
Is this a style guide thing?
Why not just:
def func(output_param=''):
output(output=output_param)
This is exactly the problem. There are a bunch of other functions that
use output='' parameter. Changing parameter name for this single
function may cause confusion.
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
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
Steven Bethard wrote:
If you ask: why do you choose these names? The answer is: they need
to be conformable with other functions, parameter names.
Is this a style guide thing?
I have a function that pretty much like:
def output(output=''):
print output
and now in another function, I
10 matches
Mail list logo