Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105047 > unrolled thread
| Started by | "Sven R. Kunze" <srkunze@mail.de> |
|---|---|
| First post | 2016-03-16 16:17 +0100 |
| Last post | 2016-03-21 17:53 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: empty clause of for loops "Sven R. Kunze" <srkunze@mail.de> - 2016-03-16 16:17 +0100
Re: empty clause of for loops Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-03-21 17:53 +0000
| From | "Sven R. Kunze" <srkunze@mail.de> |
|---|---|
| Date | 2016-03-16 16:17 +0100 |
| Subject | Re: empty clause of for loops |
| Message-ID | <mailman.216.1458141439.12893.python-list@python.org> |
On 16.03.2016 16:02, Tim Chase wrote:
> On 2016-03-16 15:29, Sven R. Kunze wrote:
>> I would re-use the "for-else" for this. Everything I thought I
>> could make use of the "-else" clause, I was disappointed I couldn't.
> Hmm...this must be a mind-set thing. I use the "else" clause with
> for/while loops fairly regularly and would be miffed if their behavior
> changed.
>
> Could I work around their absence? Certainly.
>
> Does it annoy me when I have to work in other languages that lack
> Python's {for/while}/else functionality? You bet.
I can imagine that. Could you describe the general use-case? From what I
know, "else" is executed when you don't "break" the loop. When is this
useful?
Btw., I don't have any issue with else or whatever it is called. It's
just a word but it must fit intuition. And this is why I would rather
see "else" being used there. But this may result because of the lack of
usage of mine.
We can also re-use "except" for it. ;-)
Best,
Sven
[toc] | [next] | [standalone]
| From | Rob Gaddi <rgaddi@highlandtechnology.invalid> |
|---|---|
| Date | 2016-03-21 17:53 +0000 |
| Message-ID | <ncpcea$ao2$1@dont-email.me> |
| In reply to | #105047 |
Sven R. Kunze wrote:
> On 16.03.2016 16:02, Tim Chase wrote:
>> On 2016-03-16 15:29, Sven R. Kunze wrote:
>>> I would re-use the "for-else" for this. Everything I thought I
>>> could make use of the "-else" clause, I was disappointed I couldn't.
>> Hmm...this must be a mind-set thing. I use the "else" clause with
>> for/while loops fairly regularly and would be miffed if their behavior
>> changed.
>>
>> Could I work around their absence? Certainly.
>>
>> Does it annoy me when I have to work in other languages that lack
>> Python's {for/while}/else functionality? You bet.
>
> I can imagine that. Could you describe the general use-case? From what I
> know, "else" is executed when you don't "break" the loop. When is this
> useful?
>
When you've got a sequence in which you only care about the first hit,
either because you only want one or because you know from everything
else going on in the program there can only be one.
for fn in self._containedfunctions:
if fn.__doc__ is not None:
self.__doc__ = fn.__doc__
break
else:
raise NoDocstringError("were you raised in a barn?")
--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order. See above to fix.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web