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


Groups > comp.lang.python > #65406

Re: Postfix conditionals

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'encouraging': 0.07; 'socket': 0.07; 'data:': 0.09; 'okay': 0.09; 'statements': 0.09; 'things,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'wrote': 0.14; '2.7': 0.14; "wouldn't": 0.14; '3.3,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'implemented,': 0.16; 'statements,': 0.16; 'true:': 0.16; 'two.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'split': 0.19; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'instance,': 0.24; 'simpler': 0.24; 'stick': 0.24; 'fine': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In- Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'usually': 0.31; '"",': 0.31; 'this.': 0.32; 'probably': 0.32; 'run': 0.32; 'maybe': 0.34; 'could': 0.34; 'problem': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; '2.6': 0.36; 'doing': 0.36; 'two': 0.37; 'list': 0.37; 'pm,': 0.38; 'does': 0.39; 'break': 0.61; 'today,': 0.61; 'soon': 0.63; 'line,': 0.68; 'reads': 0.68; 'statement,': 0.68; 'gone.': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=hkWq3SngeSEEfZ7/VeHyqZOXIrNJEopInLM03/uLIOc=; b=TV4A6632noT3/wQ+g9rIvJ1qGaR2DUGvD3YNMKd1tg9l0zvGMWNujuOc8m6tB/Jgs9 BVF8gSdPb4ENCAkeSRp8PwNUd6FL3W5lBYujQWBHM1+r/KGRydfz6M6OatchnCMvdReM xhJgXc2+xJ1eEKqSHecYEprIQcaSkUUjFMjk+Hevqup0HM/ZJWKMwPmuPYkIMRS4blWu 2RJKkx5aBWI97FLDfJLep2T3Dan3T1/NI6+QqowBvgQa4sclocoA3OQnRC0sVv9XFJS/ J1t+n0kX8JgZNvGy/DjTUpx17z/HrVKn+ca0Fx8kdFaE4U92BXyBjcQbjUUY/Q5OOhuf Twow==
MIME-Version 1.0
X-Received by 10.68.133.6 with SMTP id oy6mr7702464pbb.153.1391491406986; Mon, 03 Feb 2014 21:23:26 -0800 (PST)
In-Reply-To <87lhxro3u0.fsf@gkayaalp.com>
References <mailman.4966.1388953508.18130.python-list@python.org> <8SVHu.12417$MB1.2814@fx09.am4> <87lhxro3u0.fsf@gkayaalp.com>
Date Tue, 4 Feb 2014 16:23:26 +1100
Subject Re: Postfix conditionals
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
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.6379.1391491416.18130.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391491416 news.xs4all.nl 2881 [2001:888:2000:d::a6]:56447
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65406

Show key headers only | View raw


On Tue, Feb 4, 2014 at 4:16 PM, Göktuğ Kayaalp <self@gkayaalp.com> wrote:
> With my proposal implemented, the language would
> would be encouraging having multiple statements in one line, that looks
> like a single statement, but is indeed a composition of two.

I wouldn't have a problem with

if not i: break

in Python, as long as the condition is short. In something that reads
from a socket until the other end closes, for instance, I'm fine with
this:

while True:
    data = sock.read(1024)
    if not data: break
    do_stuff_with(data)

which will stop as soon as sock.read() returns "", which it does when
the other end is gone. (I wrote something doing exactly this today,
and did exactly this. Probably could have made the code a bit simpler
if I could depend on Python 3.3, but it has to run on 2.7 and maybe
2.6 so I had to stick with their facilities.)

Yes, it's two statements, but a list comprehension is a whole pile of
statement-y things, and that's usually a single line. If it's doing
one conceptual action, it's okay to not split it.

ChrisA

Back to comp.lang.python | Previous | NextPrevious 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