Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'syntax': 0.03; 'badly': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'language': 0.14; '*and': 0.16; 'different,': 0.16; 'iterable,': 0.16; 'iterable:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:when': 0.16; 'trap': 0.16; 'users.': 0.16; 'wrote:': 0.17; 'saying': 0.18; 'planet': 0.22; 'programming': 0.23; 'feature': 0.24; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'setting': 0.26; 'header:X-Complaints-To:1': 0.28; 'writes:': 0.29; 'keyword': 0.30; 'to:addr:python-list': 0.33; 'something': 0.35; 'there': 0.35; 'received:org': 0.36; "didn't": 0.36; 'item': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'time,': 0.62; 'thomas': 0.62; 'perfect': 0.63; 'making': 0.64; 'covers': 0.65; 'else.': 0.65; 'believe': 0.69; 'frank': 0.75; 'introduce': 0.80; 'against,': 0.84; 'break.': 0.84; 'redefining': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Frank Millman Subject: Re: Else statement executing when it shouldnt Date: Fri, 25 Jan 2013 10:15:56 +0200 References: <2cc6791f-ba56-406c-a5b0-b23023caf4bb@googlegroups.com> <20130122163924.74038876@sampi> <20130122164835.74a0ebf6@sampi> <66a33143-c4e5-400d-b6eb-2305a345ca3e@ro7g2000pbb.googlegroups.com> <20130123122247.43031d2e@sampi> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 197.87.30.24 User-Agent: Mozilla/5.0 (Windows NT 5.2; rv:14.0) Gecko/20120713 Thunderbird/14.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1359101769 news.xs4all.nl 6932 [2001:888:2000:d::a6]:60144 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37653 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