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


Groups > comp.lang.python > #21014

Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.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; 'else:': 0.03; 'subject:when': 0.07; 'python': 0.08; 'exited': 0.09; 'received:10.50': 0.09; 'programmer': 0.10; 'am,': 0.12; 'confusing.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'likewise': 0.16; 'syntactic': 0.16; 'then:': 0.16; 'syntax': 0.16; 'wed,': 0.17; 'wrote:': 0.18; 'received:209.85.210.174': 0.21; 'received:mail- iy0-f174.google.com': 0.21; 'header:In-Reply-To:1': 0.22; 'feb': 0.22; 'suite,': 0.23; 'structure': 0.26; 'message- id:@mail.gmail.com': 0.29; '24,': 0.29; 'syntax,': 0.30; 'break': 0.32; 'too': 0.33; 'steven': 0.34; 'subject:/': 0.34; 'to:addr :python-list': 0.35; 'however,': 0.35; 'run': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'think': 0.38; 'should': 0.38; 'johnson': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.40; 'header:Received:6': 0.61; '29,': 0.73; 'expects': 0.84
Received-SPF pass (google.com: domain of rosuav@gmail.com designates 10.50.207.72 as permitted sender) client-ip=10.50.207.72;
Authentication-Results mr.google.com; spf=pass (google.com: domain of rosuav@gmail.com designates 10.50.207.72 as permitted sender) smtp.mail=rosuav@gmail.com; dkim=pass header.i=rosuav@gmail.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=zz03IwO7YbxCGbNNwPuSgqLBvLDNyLknIwEaDHEPUhE=; b=AJUCf8SBMRgPPftL5/8CkSUUJKi90MmM4wB5KY5wP9CfrHOwScHYMw18bqCU3Juwvg ohEMtWPqf3Ew1NXnm2HoHCOW10ygTDkV2TimbWXXOXK9b9gBfroaXGhBySRR3JHoKsQF GDo+piQ+3j7l0/BewkkMv5lfIH2toaQWXmons=
MIME-Version 1.0
In-Reply-To <f785f5f6-2c4b-4f5d-a81e-3396cd196b0f@f4g2000yqh.googlegroups.com>
References <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> <ji80lm$rtc$1@solani.org> <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> <f785f5f6-2c4b-4f5d-a81e-3396cd196b0f@f4g2000yqh.googlegroups.com>
Date Wed, 29 Feb 2012 10:24:18 +1100
Subject Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
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.269.1330471462.3037.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1330471462 news.xs4all.nl 6903 [2001:888:2000:d::a6]:59009
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:21014

Show key headers only | View raw


On Wed, Feb 29, 2012 at 9:56 AM, Rick Johnson
<rantingrickjohnson@gmail.com> wrote:
> On Feb 24, 8:54 am, Steven D'Aprano <steve
> +comp.lang.pyt...@pearwood.info> wrote:
>
>> In Python 4000, I think for loops should be spelled:
>>
>> for name in iterable:
>>     # for block
>> then:
>>     # only if not exited with break
>> else:
>>     # only if iterable is empty
>>
>> and likewise for while loops.
>
> I like this syntax better than the current syntax, however, it is
> STILL far too confusing!

Absolutely, it's FAR too confusing. Every syntactic structure should
have the addition of a "foo:" suite, which will run when the
programmer expects it to and no other time. This would solve a LOT of
problems.

ChrisA

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


Thread

A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Alex Willmer <alex@moreati.org.uk> - 2012-02-23 16:30 -0800
  Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-02-24 01:08 +0000
    Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Ethan Furman <ethan@stoneleaf.us> - 2012-02-23 19:49 -0800
    Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-02-24 07:10 +0000
    Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Peter Otten <__peter__@web.de> - 2012-02-24 09:44 +0100
  Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Paul Rubin <no.email@nospam.invalid> - 2012-02-23 17:21 -0800
  Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Rick Johnson <rantingrickjohnson@gmail.com> - 2012-02-24 04:32 -0800
    Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Peter Otten <__peter__@web.de> - 2012-02-24 13:44 +0100
      Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Peter Otten <__peter__@web.de> - 2012-02-24 14:14 +0100
      Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-02-24 14:54 +0000
        Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Arnaud Delobelle <arnodel@gmail.com> - 2012-02-24 15:00 +0000
        Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Peter Otten <__peter__@web.de> - 2012-02-24 16:16 +0100
        Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Rick Johnson <rantingrickjohnson@gmail.com> - 2012-02-28 14:56 -0800
          Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Chris Angelico <rosuav@gmail.com> - 2012-02-29 10:24 +1100
            Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-02-29 00:18 +0000

csiph-web