12 ms·
yeah in raku, i checked say False.so; #False
by librasteve 1y ago
yeah
in raku, i checked
say False.so; #False
- Jtsummers 1y agoIf I understand raku correctly, the Python example would be more like this: say "False".Bool or: say "False".so Both of which display True. Leaving out the quotes means you're testing something else entirely. Note that the Python example is converting (via `bool`) a string with the text "false" (which would make more sense as "False" which is the actual name of `False` in Python) into a boolean value. It's consistent with how Python behaves, in that the empty string (like in Raku from what I can tell) is false-y and non-empty strings are truth-y. It would be weird to have this use the else branch: if bool("False"): ... else: ... But not this: if "False": ... else: ...
- gpderetta 1y agoAs mentioned else thread, the problem is not so much that book("false") evaluates to true, which is consistent with a lot of the language, but that int("1") evaluates to 1. Generally python is much better than some other dynamic languages in avoiding stringly typed confusion, but the convenience of the int from string constructor set expectations that the rest of the language can't sanely meet. String to type construction should have been relegated to a dedicated syntax in all cases.
- librasteve 1y agothanks for the correction