[Tutor] Is defining functions as dummies pythonic?

Alan Gauld alan.gauld at blueyonder.co.uk
Fri Apr 16 13:47:30 EDT 2004


>> def verbosize (string):
>>     if isverbose:
>>         print string
>>     else:
>>         pass
>
> But doesn't that mean that every time this function is called, the
program
> has to do the test all over again, even though I already have the
> information from the start? This sound hideously inefficient...

Not hideously inefficient - the function call is more expensive
than the test. But it is less efficient than your conditional
function defintion.

Alan G






More information about the Tutor mailing list