Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10433

Re: Pipe in the "return" statement

Message-ID <5540261.NEBpaLTAqx@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2011-07-28 08:26 +0200
Subject Re: Pipe in the "return" statement
Newsgroups comp.lang.python
References <acaab166-32c1-43df-b1a4-e3b47c62be36@m10g2000yqd.googlegroups.com> <9954ddFkjuU10@mid.individual.net> <1c175da2-79f4-40ed-803f-217dc935df6c@m8g2000yqo.googlegroups.com> <j0juod$193$1@speranza.aioe.org> <mailman.1472.1311623510.1164.python-list@python.org>
Followup-To comp.lang.python

Followups directed to: comp.lang.python

Show all headers | View raw


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...@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), 
probably.
 
-- 
PointedEars

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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Pipe in the "return" statement Archard Lias <archardlias@googlemail.com> - 2011-07-25 05:00 -0700
  Re: Pipe in the "return" statement Ian Collins <ian-news@hotmail.com> - 2011-07-26 00:03 +1200
    Re: Pipe in the "return" statement Archard Lias <archardlias@googlemail.com> - 2011-07-25 07:16 -0700
      Re: Pipe in the "return" statement Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> - 2011-07-25 10:31 -0400
        Re: Pipe in the "return" statement Ethan Furman <ethan@stoneleaf.us> - 2011-07-25 13:07 -0700
          Re: Pipe in the "return" statement Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-07-28 08:26 +0200
      Re: Pipe in the "return" statement Oliver Bestwalter <oliver@bestwalter.de> - 2011-07-25 16:35 +0200
        Re: Pipe in the "return" statement Archard Lias <archardlias@googlemail.com> - 2011-07-25 08:05 -0700
      Re: Pipe in the "return" statement John Gordon <gordon@panix.com> - 2011-07-25 14:39 +0000
        Re: Pipe in the "return" statement Archard Lias <archardlias@googlemail.com> - 2011-07-25 08:06 -0700
      Re: Pipe in the "return" statement gwowen <gwowen@gmail.com> - 2011-07-25 07:42 -0700
  Re: Pipe in the "return" statement Christian Heimes <lists@cheimes.de> - 2011-07-25 14:33 +0200
    Re: Pipe in the "return" statement Archard Lias <archardlias@googlemail.com> - 2011-07-25 08:28 -0700
      Re: Pipe in the "return" statement Christian Heimes <lists@cheimes.de> - 2011-07-25 18:11 +0200
        Re: Pipe in the "return" statement Archard Lias <archardlias@googlemail.com> - 2011-07-25 09:30 -0700
  Re: Pipe in the "return" statement TonyO <guinness.tony@gmail.com> - 2011-07-25 05:52 -0700
    Re: Pipe in the "return" statement gwowen <gwowen@gmail.com> - 2011-07-25 06:00 -0700
    Re: Pipe in the "return" statement red floyd <redfloyd@gmail.com> - 2011-07-25 14:04 -0700
      reading  zipfile; problem using raw buffer "Sells, Fred" <fred.sells@adventistcare.org> - 2011-07-26 08:42 -0400
        Re: reading  zipfile; problem using raw buffer Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> - 2011-07-26 08:49 -0400
      Re: reading  zipfile; problem using raw buffer Peter Otten <__peter__@web.de> - 2011-07-26 15:04 +0200
      RE: reading  zipfile; problem using raw buffer "Sells, Fred" <fred.sells@adventistcare.org> - 2011-07-26 11:22 -0400

csiph-web