Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37653
| From | Frank Millman <frank@chagford.com> |
|---|---|
| Subject | Re: Else statement executing when it shouldnt |
| Date | 2013-01-25 10:15 +0200 |
| References | (5 earlier) <mailman.799.1358869356.2939.python-list@python.org> <20130122164835.74a0ebf6@sampi> <66a33143-c4e5-400d-b6eb-2305a345ca3e@ro7g2000pbb.googlegroups.com> <20130123122247.43031d2e@sampi> <qotbocg58f2.fsf@ruuvi.it.helsinki.fi> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1030.1359101769.2939.python-list@python.org> (permalink) |
On 23/01/2013 15:35, Jussi Piitulainen wrote:
> Thomas Boell writes:
>
>> Using a keyword that has a well-understood meaning in just about
>> every other programming language on the planet *and even in
>> English*, redefining it to mean something completely different, and
>> then making the syntax look like the original, well-understood
>> meaning -- that's setting a trap out for users.
>>
>> The feature isn't bad, it's just very, very badly named.
>
> I believe it would read better - much better - if it was "for/then"
> and "while/then" instead of "for/else" and "while/else".
>
> I believe someone didn't want to introduce a new keyword for this,
> hence "else".
>
There is a scenario, which I use from time to time, where 'else' makes
perfect sense.
You want to loop through an iterable, looking for 'something'. If you
find it, you want to do something and break. If you do not find it, you
want to do something else.
for item in iterable:
if item == 'something':
do_something()
break
else: # item was not found
do_something_else()
Not arguing for or against, just saying it is difficult to find one word
which covers all requirements.
Frank Millman
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:40 -0800
Re: Else statement executing when it shouldnt Roy Smith <roy@panix.com> - 2013-01-20 23:47 -0500
Re: Else statement executing when it shouldnt Chris Angelico <rosuav@gmail.com> - 2013-01-21 15:52 +1100
Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:55 -0800
Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:55 -0800
Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:54 -0800
Re: Else statement executing when it shouldnt alex23 <wuwei23@gmail.com> - 2013-01-20 22:00 -0800
Re: Else statement executing when it shouldnt Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-21 08:04 +0000
Re: Else statement executing when it shouldnt René Klačan <rene.klacan@gmail.com> - 2013-01-21 05:54 +0100
Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:57 -0800
Re: Else statement executing when it shouldnt René Klačan <rene.klacan@gmail.com> - 2013-01-21 06:06 +0100
Re: Else statement executing when it shouldnt René Klačan <rene.klacan@gmail.com> - 2013-01-21 06:07 +0100
Re: Else statement executing when it shouldnt Thomas Boell <tboell@domain.invalid> - 2013-01-22 16:39 +0100
Re: Else statement executing when it shouldnt Chris Angelico <rosuav@gmail.com> - 2013-01-23 02:42 +1100
Re: Else statement executing when it shouldnt Thomas Boell <tboell@domain.invalid> - 2013-01-22 16:48 +0100
Re: Else statement executing when it shouldnt Chris Angelico <rosuav@gmail.com> - 2013-01-23 03:07 +1100
Re: Else statement executing when it shouldnt Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-22 23:22 +0000
Re: Else statement executing when it shouldnt René Klačan <rene.klacan@gmail.com> - 2013-01-23 01:34 +0100
Re: Else statement executing when it shouldnt Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-01-22 22:11 -0500
Re: Else statement executing when it shouldnt alex23 <wuwei23@gmail.com> - 2013-01-22 17:28 -0800
Re: Else statement executing when it shouldnt Thomas Boell <tboell@domain.invalid> - 2013-01-23 12:22 +0100
Re: Else statement executing when it shouldnt Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-01-23 15:35 +0200
Re: Else statement executing when it shouldnt Jerry Hill <malaclypse2@gmail.com> - 2013-01-23 09:53 -0500
Re: Else statement executing when it shouldnt Frank Millman <frank@chagford.com> - 2013-01-25 10:15 +0200
Re: Else statement executing when it shouldnt Duncan Booth <duncan.booth@invalid.invalid> - 2013-01-22 15:48 +0000
Re: Else statement executing when it shouldnt Duncan Booth <duncan.booth@invalid.invalid> - 2013-01-22 15:52 +0000
Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:57 -0800
Re: Else statement executing when it shouldnt Mitya Sirenef <msirenef@lightbird.net> - 2013-01-20 23:57 -0500
Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:59 -0800
Re: Else statement executing when it shouldnt Mitya Sirenef <msirenef@lightbird.net> - 2013-01-21 01:09 -0500
Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-20 20:59 -0800
Re: Else statement executing when it shouldnt alex23 <wuwei23@gmail.com> - 2013-01-20 21:46 -0800
Re: Else statement executing when it shouldnt alex23 <wuwei23@gmail.com> - 2013-01-20 21:56 -0800
Re: Else statement executing when it shouldnt eli m <techgeek201@gmail.com> - 2013-01-21 07:37 -0800
Re: Else statement executing when it shouldnt Chris Angelico <rosuav@gmail.com> - 2013-01-22 05:44 +1100
csiph-web