Neal Becker wrote: > Instead, bool fails in _the worst possible way_: it silently gives a > _wrong result_. I disagree with the word "fail" there; Python is working correctly. The behavior of converting expressions to a boolean is well-defined: http://docs.python.org/ref/Booleans.html Perhaps the behavior is unexpected or unwelcome--but it is *correct*. It's just one of those things about Python that one has to get used to; this is a side-effect of another, much more important principle. If you really want to turn the string "True" into True, use "eval". eval("4") -> 4 eval("True") -> True eval("{}") -> {} Perhaps it would be safest to cast the output of eval to bool: bool(eval("True")) -> True bool(eval("")) -> False Cheers, /larry/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20070222/15e6eb76/attachment-0001.html
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4