Closed dmytrokyrychuk closed 9 years ago
what do you think about adding something like that?
>>> False==0
True
>>> str(False)==str(0)
False
It is expected that string representations of two different objects of two different types are different. It would've been worth adding if there was a place for
>>> str(bool(False)) == str(bool(0))
False
But the correct result is:
>>> str(bool(False)) == str(bool(0))
True
So personally I do not think it should be added.
thank you for detailed reply
Yeah I agree this is a little too straightforward. I've removed it. Thanks for the feedback!
String is considered false when it is empty, so as other sequences (lists, tuples, sets, etc.). It's described in right here.
str(False)
is'False'
.'False'
is non-empty string, sobool('False')
isTrue
, same asbool('any other non-empty string')
. Seems reasonable to me.