How to do "new_variable = (variable) ? True : False;" (php) on python?
Scott David Daniels
scott.daniels at acm.org
Fri Nov 18 17:15:06 EST 2005
Peter Otten wrote:
> Daniel Crespo wrote:
>>new_variable = (variable) ? True : False;
>>in Python in one line?
> new_variable = variable
Of course to answer your actual question:
new_variable = variable and True or False
But you should consider that Peter has given
you a better answer than you think.
<yoda>
Don't try to force everything to the type you expect,
use things as they are; embrace duck-typing.
</yoda>
:-)
--Scott David Daniels
scott.daniels at acm.org
More information about the Python-list
mailing list