Pipe in the "return" statement

Thomas 'PointedEars' Lahn PointedEars at web.de
Thu Jul 28 08:26:12 CEST 2011

Ethan Furman wrote:

> Billy Mays wrote:
>> On 07/25/2011 10:16 AM, Archard Lias wrote:
>>> On Jul 25, 2:03 pm, Ian Collins<ian-n... at hotmail.com>  wrote:
>>>> On 07/26/11 12:00 AM, Archard Lias wrote:
>>>>> Still I dont get how I am supposed to understand the pipe and its
>>>>> task/ idea/influece on control flow, of:
>>>>> return<statement>    |<statement>
>>>>> ??
>>>> It's simply a bitwise OR.
>>> Yes, but how does it get determined, which one actually gets returned?
>> The return statement returns a single value from a function context. The
>> pipe operator takes 2 values and bitwise ORs* them together.  That
>> result is then returned to the caller.
> Just for completeness, if the actual line had been
> return <statement1> or <statement2>
> then Python would compute <statement1>, and if its boolean value was
> True would return the computation of <statement1>, otherwise it would
> compute <statement2> and return that.  When 'or' is used, the first
> truthy* item is return, or the last falsey* item if none evaluate to True.

Hence "*bitwise* OR" (as Billy wrote), _not_ logical OR (as you wrote), 

Bitte keine Kopien per E-Mail. / Please do not Cc: me.

More information about the Python-list mailing list