Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10305
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ethan@stoneleaf.us> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:" ': 0.03; 'operator': 0.05; 'python': 0.08; '>>>>': 0.09; 'caller.': 0.09; 'compute': 0.09; 'context.': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:gator410.hostgator.com': 0.09; 'return,': 0.09; '~ethan~': 0.09; '25,': 0.12; 'am,': 0.13; 'wrote:': 0.15; 'billy': 0.16; 'bitwise': 0.16; 'boolean': 0.16; 'computation': 0.16; 'object)': 0.16; 'or.': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'returned,': 0.16; 'pm,': 0.16; '>>>': 0.16; 'header:In-Reply- To:1': 0.22; 'collins': 0.23; 'statement': 0.25; 'function': 0.26; 'values': 0.31; 'expression': 0.32; 'used,': 0.32; 'does': 0.32; 'together.': 0.33; 'actually': 0.33; 'to:addr:python-list': 0.34; 'header:User-Agent:1': 0.34; 'none': 0.35; 'actual': 0.35; 'supposed': 0.35; 'unless': 0.37; 'but': 0.37; 'takes': 0.38; 'subject:: ': 0.38; 'case': 0.39; 'returned': 0.39; 'to:addr:python.org': 0.39; 'hope': 0.60; 'received:websitewelcome.com': 0.65; 'received:184': 0.67; 'received:69.93': 0.67; 'evaluate': 0.71; '10:16': 0.84; '-->': 0.91; 'received:gateway02.websitewelcome.com': 0.93 |
| Date | Mon, 25 Jul 2011 13:07:08 -0700 |
| From | Ethan Furman <ethan@stoneleaf.us> |
| User-Agent | Thunderbird 1.5.0.10 (Windows/20070221) |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Pipe in the "return" statement |
| 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> |
| In-Reply-To | <j0juod$193$1@speranza.aioe.org> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-AntiAbuse | This header was added to track abuse, please include it with any abuse report |
| X-AntiAbuse | Primary Hostname - gator410.hostgator.com |
| X-AntiAbuse | Original Domain - python.org |
| X-AntiAbuse | Originator/Caller UID/GID - [47 12] / [47 12] |
| X-AntiAbuse | Sender Address Domain - stoneleaf.us |
| X-BWhitelist | no |
| X-Source | |
| X-Source-Args | |
| X-Source-Dir | |
| X-Source-Sender | mail.admailinc.com ([192.168.10.136]) [72.11.125.166]:2746 |
| X-Source-Auth | ethan+stoneleaf.us |
| X-Email-Count | 2 |
| X-Source-Cap | dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1472.1311623510.1164.python-list@python.org> (permalink) |
| Lines | 47 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1311623510 news.xs4all.nl 23952 [2001:888:2000:d::a6]:53039 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:10305 |
Show key headers only | View raw
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. --> None or 2 or 0 2 --> None or 2 or 3 2 --> None or [] or 0 0 With 'and', the first falsey item is returned, unless all the items are truthy in which case the last item is returned: --> 2 and 3 3 --> 2 and 0 and 9 0 Hope this helps. ~Ethan~ * 'truthy' = bool(some expression or object) == True * 'falsey' = bool(some expression or object) == False
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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