cosmologicon / pywat

Python wats
1.22k stars 99 forks source link

Converting to a string and back wat is not a wat #17

Closed dmytrokyrychuk closed 9 years ago

dmytrokyrychuk commented 9 years ago

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, so bool('False') is True, same as bool('any other non-empty string'). Seems reasonable to me.

ogroleg commented 9 years ago

what do you think about adding something like that?

>>> False==0
True
>>> str(False)==str(0)
False
dmytrokyrychuk commented 9 years ago

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.

ogroleg commented 9 years ago

thank you for detailed reply

cosmologicon commented 9 years ago

Yeah I agree this is a little too straightforward. I've removed it. Thanks for the feedback!