On 1/17/2013 8:10 AM, Ilkka Pelkonen wrote:
Hi Oleg, others,
It's not that it can't be done, just that it does something you don't expect. I've been professionally working with C++ for nine years in large-scale Windows systems, and I do expect a boolean expression return a boolean value.

Or, can you show me an example how the developer would benefit of the current behavior? Any operator traditionally considered as boolean will do.

Regards,
Ilkka

Ilkka, welcome to the Python community.  Python is a wonderfully expressive language once you learn its subtleties.

Python and C++ are different.  If they weren't, we'd only have one language, not two.  The short-circuiting operations "and" and "or" behave as they do for a reason.  As an example, a common way to deal with default values:

    def accumulate(value, to=None):
        to = to or []
        to.append(value)
        # Forget whether this is a good function or not..
        return to

If "or" always returned a boolean, as I'm assuming you'd prefer, then we'd have a much clumsier time defaulting values like this.

--Ned.