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


Groups > comp.lang.python > #63274

Re: Postfix conditionals

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <self@gkayaalp.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.015
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'python,': 0.02; 'perl,': 0.07; 'postfix': 0.07; 'english,': 0.09; 'python:': 0.09; 'runs': 0.10; 'jan': 0.12; 'wrote': 0.14; 'conditional': 0.16; 'determines': 0.16; 'readability': 0.16; 'received:72.5': 0.16; 'received:72.5.230': 0.16; 'received:sender1.zohomail.com': 0.16; 'received:zohomail.com': 0.16; 'wrote:': 0.18; 'properly': 0.19; 'examples': 0.20; 'code,': 0.22; 'example': 0.22; 'header:User- Agent:1': 0.23; 'looks': 0.24; 'equivalent': 0.26; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'compared': 0.30; 'statement': 0.30; 'code': 0.31; 'easier': 0.31; 'too.': 0.31; 'idea,': 0.31; 'piece': 0.31; 'quite': 0.32; "i'd": 0.34; 'except': 0.35; 'but': 0.35; 'i.e.': 0.36; "didn't": 0.36; 'thanks': 0.36; 'received:192.168.2': 0.37; 'two': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; 'break': 0.61; 'from:charset:utf-8': 0.61; 'simple': 0.61; 'first': 0.61; 'back': 0.62; 'more': 0.64; 'life': 0.66; 'sample': 0.67; 'believe': 0.68; 'statement,': 0.68; 'results': 0.69; 'superior': 0.69; 'discovered': 0.83; 'newcomer': 0.84; 'not:': 0.91
Date Mon, 06 Jan 2014 09:51:28 +0200
From Göktuğ Kayaalp <self@gkayaalp.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Postfix conditionals
References <mailman.4966.1388953508.18130.python-list@python.org> <op.w88r80z25079vu@gnudebeest>
In-Reply-To <op.w88r80z25079vu@gnudebeest>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-ZohoMailClient External
X-Zoho-Virus-Status 2
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5010.1388994695.18130.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1388994695 news.xs4all.nl 2932 [2001:888:2000:d::a6]:40450
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63274

Show key headers only | View raw


On 06-01-2014 03:40, Rhodri James wrote:
> On Sun, 05 Jan 2014 20:24:53 -0000, Göktuğ Kayaalp <self@gkayaalp.com> 
> wrote:
>
>> AFAIK, we do not have "postfix conditionals" in Python, i.e. a 
>> condition appended to a statement, which determines whether the 
>> statement runs or not:
>
>>    py> for i in [False]:
>>    ...     break if not i
>
>>  The above piece of code is equivalent to this in Python:
>
>>    py> for i in [False]:
>>    ...    if not i
>>    ...        break
>
>> I believe that the first example is superior to the second example 
>> when the two is compared for readability and intuitiveness.
>
> In my past life as a newcomer to Perl, I thought this too. Postfix 
> conditionals read more like English, so they would be easier to take 
> in and understand.  As I wrote more code, I discovered that this 
> didn't seem to be the case; except in very simple cases, I had to 
> mentally transpose the conditional back to the start of the statement 
> to properly comprehend what was going on and what the results would be 
> for my sample data.
>
> It looks like a good idea, but I don't think it works that well in 
> practice.
>
Thanks for the input! I'd be quite interested in examples which required 
you to "mentally transpose the conditional back to the start of the 
statement", by the way.

         gk

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


Thread

Postfix conditionals Göktuğ Kayaalp <self@gkayaalp.com> - 2014-01-05 22:24 +0200
  Re: Postfix conditionals Roy Smith <roy@panix.com> - 2014-01-05 15:41 -0500
    Re: Postfix conditionals Göktuğ Kayaalp <self@gkayaalp.com> - 2014-01-05 22:54 +0200
    Re: Postfix conditionals Dan Stromberg <drsalists@gmail.com> - 2014-01-05 13:08 -0800
  Re: Postfix conditionals "Rhodri James" <rhodri@wildebst.org.uk> - 2014-01-06 01:40 +0000
    Re: Postfix conditionals Göktuğ Kayaalp <self@gkayaalp.com> - 2014-01-06 09:51 +0200
      Re: Postfix conditionals "Rhodri James" <rhodri@wildebst.org.uk> - 2014-01-07 00:48 +0000
  Re: Postfix conditionals "BartC" <bc@freeuk.com> - 2014-02-03 23:43 +0000
    Re: Postfix conditionals Göktuğ Kayaalp <self@gkayaalp.com> - 2014-02-04 07:16 +0200
      Re: Postfix conditionals "BartC" <bc@freeuk.com> - 2014-02-04 10:00 +0000
    Re: Postfix conditionals Chris Angelico <rosuav@gmail.com> - 2014-02-04 16:23 +1100

csiph-web