Python idiom for '... if ... else ...' expression
Posted
by rukeba
on Stack Overflow
See other posts from Stack Overflow
or by rukeba
Published on 2010-03-27T14:02:50Z
Indexed on
2010/03/27
14:03 UTC
Read the original article
Hit count: 234
Hello!
How to write the exprission shorter:
return '%.0f' % float_var if float_var else float_var
or
if float_var:
return formatted_string
else:
return None
Thanks!
© Stack Overflow or respective owner