Returning a string from a boolean
Dan Rawson
daniel.rawson.take!this!out! at asml.nl
Tue Aug 12 08:14:06 EDT 2003
I need to return "True" or "False" strings for a boolean value (mostly for display purposes).
It's obviously trivial to write the function:
def bStr (bVar):
if bVar:
return 'True'
else:
return 'False'
In Perl I can do this with the ternary 'if'
(bVar) ? 'True' : 'False'
Is there a simpler way in Python??
If it makes a difference, I'm using 2.2.2 (on Solaris) with no chance of going to 2.3 in the near future <g>; I know
that some of this has changed in 2.3.
TIA . . .
Dan
More information about the Python-list
mailing list