On Mon, 19 Sep 2005 12:16:15 +0200, sven wrote: > to make sure that an operation yields a boolean value wrap a bool() > around an expression. > None, 0 and objects which's len is 0 yield False. > so you can also do stuff like that:
Are there actually any usage cases for *needing* a Boolean value? Any object can be used for truth testing, eg: if the_str is to be preferred over: if bool(the_str) or even worse: if bool(the_str != "") Or wait, I have thought of one usage case: if you are returning a value that you know will be used only as a flag, you should convert it into a bool. Are there any other uses for bool()? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list