Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105039
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | "Sven R. Kunze" <srkunze@mail.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: empty clause of for loops |
| Date | Wed, 16 Mar 2016 15:39:41 +0100 |
| Lines | 43 |
| Message-ID | <mailman.212.1458139185.12893.python-list@python.org> (permalink) |
| References | <56E93413.6090108@mail.de> <ncbdk4$h9u$1@ger.gmane.org> <56E94EB9.9050507@mail.de> <ncbl8p$hq6$1@ger.gmane.org> <56E96DDA.30008@mail.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de F1ydCpzXqaFzt3fnQbyEAw+Pi7hMym/Wef2iF10m4HGQ== |
| Return-Path | <srkunze@mail.de> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.060 |
| X-Spam-Evidence | '*H*': 0.88; '*S*': 0.00; 'else:': 0.03; 'considered.': 0.09; 'throw': 0.09; 'syntax': 0.13; 'clause,': 0.16; 'clause.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'stdlib.': 0.16; 'syntactical': 0.16; 'wrote:': 0.16; ';-)': 0.18; 'exceptions': 0.22; 'function,': 0.22; '(or': 0.23; 'header :In-Reply-To:1': 0.24; 'feature': 0.24; 'room': 0.27; 'least': 0.27; 'question': 0.27; 'cool': 0.27; 'function': 0.28; 'this.': 0.28; "i'd": 0.31; 'implement': 0.32; 'language.': 0.32; 'useful': 0.33; 'received:10.0': 0.34; 'best,': 0.35; 'could': 0.35; 'quite': 0.35; 'something': 0.35; 'item': 0.35; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'requirement': 0.37; 'thought': 0.37; 'why': 0.39; 'easily': 0.39; 'rather': 0.39; 'well.': 0.40; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'your': 0.60; 'charset:windows-1252': 0.62; 'personal': 0.63; 'benefit': 0.66; 'choose': 0.68; 'answer:': 0.84; 'asked.': 0.84; 'conceived': 0.84; 'disappointed': 0.84; 'otten': 0.84; 'glad': 0.87; 'severe': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mail201212; t=1458139182; bh=8p3Uuf6DCCSWPy96xkkVisNrPR6kU799GDpaa3KrcAk=; h=Subject:To:References:From:Date:In-Reply-To:From; b=wlGitthO49OQWTpS0JlCl4QkWTJHHvsjeOjRgjTTainq+Hbe7xBL7+Mj8VfCVngX9 px/T08GmB0124rp5A7Bgx0azGMSfj4YBXO3umlfxpAXYUW6DrJa0QvdacXPG/aFZ/W ge5zeML+pMAu67KpvGpUNQcM310rQFflqsC2fTXk= |
| In-Reply-To | <56E96DDA.30008@mail.de> |
| X-purgate | clean |
| X-purgate | This mail is considered clean (visit http://www.eleven.de for further information) |
| X-purgate-type | clean |
| X-purgate-Ad | Categorized by eleven eXpurgate (R) http://www.eleven.de |
| X-purgate | This mail is considered clean (visit http://www.eleven.de for further information) |
| X-purgate | clean |
| X-purgate-size | 1315 |
| X-purgate-ID | 154282::1458139182-00003BBD-6DD2C619/0/0 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:105039 |
Show key headers only | View raw
On 16.03.2016 15:29, Sven R. Kunze wrote: > On 16.03.2016 13:57, Peter Otten wrote: >> >> I'd put that the other way round: syntactical support for every pattern >> would make for a rather unwieldy language. You have to choose >> carefully, and >> this requirement could easily be fulfilled by a function, first in your >> personal toolbox, then in a public libary, then in the stdlib. >> >> If you don't like exceptions implement (or find) something like >> >> items = peek(items) >> if items.has_more(): >> # at least one item >> for item in items: >> ... >> else: >> # empty >> >> Only if such a function is used a lot or cannot be conceived without >> severe >> shortcumings adding to the syntax should be considered. The >> (hypothetical) >> question you should answer: which current feature would you throw out to >> make room for your cool new addition? > > I am glad you asked. ;-) > > 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. > [everytime] > > I find the addition to for-loop as useful as we already have a quite > complex try-except-else-finally clause. I don't know why for-loops > couldn't benefit from this as well. > > > Best, > Sven
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: empty clause of for loops "Sven R. Kunze" <srkunze@mail.de> - 2016-03-16 15:39 +0100
csiph-web