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

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 2012-02-29 10:24 +1100
Subject Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.269.1330471462.3037.python-list@python.org> (permalink)

Show all headers | 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