Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105040
| From | "Sven R. Kunze" <srkunze@mail.de> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: empty clause of for loops |
| Date | 2016-03-16 15:44 +0100 |
| Message-ID | <mailman.213.1458139469.12893.python-list@python.org> (permalink) |
| References | <mailman.186.1458123807.12893.python-list@python.org> <56e94cd9$0$22142$c3e8da3$5496439d@news.astraweb.com> |
On 16.03.2016 13:08, Steven D'Aprano wrote: > Doing what? What is the code supposed to do? What's "empty" mean as a > keyword? > > If you explain what your friends wants, then perhaps we can suggest > something. Otherwise we're just guessing. I can think of at least two > different meanings: > > * run the "empty" block only if my_iterable is empty at the start of the > first loop; Solutions of most commenters already tackled this one, which is (at least from my point of view) the most intuitive. > * run the "empty" block if my_iterable becomes empty after the first loop. I think I can imagine where this is coming from but this was not the initial use-case. I think Tim's answer (count approach) would provide a solution for this (from my point of view) rather rare use-case. Best, Sven
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
empty clause of for loops "Sven R. Kunze" <srkunze@mail.de> - 2016-03-16 11:23 +0100
Re: empty clause of for loops Steven D'Aprano <steve@pearwood.info> - 2016-03-16 23:08 +1100
Re: empty clause of for loops "Sven R. Kunze" <srkunze@mail.de> - 2016-03-16 15:44 +0100
Re: empty clause of for loops André Roberge <andre.roberge@gmail.com> - 2016-03-16 05:41 -0700
Re: empty clause of for loops Steven D'Aprano <steve@pearwood.info> - 2016-03-16 23:59 +1100
Re: empty clause of for loops Peter Otten <__peter__@web.de> - 2016-03-16 14:04 +0100
Re: empty clause of for loops Palpandi <palpandi111@gmail.com> - 2016-03-18 12:10 -0700
csiph-web