Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82422
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'from:addr:yahoo.co.uk': 0.04; 'syntax': 0.04; 'assignment': 0.07; 'granted,': 0.07; 'odd': 0.07; 'parser': 0.07; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rejected': 0.09; 'subject:while': 0.09; 'python': 0.11; 'language.': 0.14; 'fork': 0.16; 'imo,': 0.16; 'loops': 0.16; 'partly': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'recognise': 0.16; 'repetition,': 0.16; 'restructured': 0.16; 'umpteen': 0.16; 'value;': 0.16; 'variants': 0.16; 'language': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'pointed': 0.19; 'slightly': 0.19; 'thoughts': 0.19; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'looks': 0.24; "i've": 0.25; 'compare': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'wondering': 0.29; 'code': 0.31; 'this.': 0.32; 'languages': 0.32; '(e.g.': 0.33; 'something': 0.35; 'but': 0.35; 'similar': 0.36; 'list': 0.37; 'being': 0.38; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'little': 0.38; 'though,': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'break': 0.61; 'course': 0.61; 'times': 0.62; 'such': 0.63; 'happen': 0.63; 'our': 0.64; 'more': 0.64; 'different': 0.65; 'charset:windows-1252': 0.65; 'due': 0.66; '2.8': 0.84; 'dry': 0.84; 'subject:Extension': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
| Subject | Re: Extension of while syntax |
| Date | Fri, 12 Dec 2014 08:00:56 +0000 |
| References | <14d2b880-3837-4267-a769-33ae7393f78b@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | host-92-18-27-211.as13285.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 |
| In-Reply-To | <14d2b880-3837-4267-a769-33ae7393f78b@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16897.1418371273.18130.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1418371273 news.xs4all.nl 2876 [2001:888:2000:d::a6]:33465 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:82422 |
Show key headers only | View raw
On 12/12/2014 02:21, Nelson Crosby wrote:
> I was thinking a bit about the following pattern:
>
> value = get_some_value()
> while value in undesired_values:
> value = get_some_value()
>
> I've always hated code that looks like this. Partly due to the repetition, but partly also due to the fact that without being able to immediately recognise this pattern, it isn't very readable.
>
> Python already has one-line syntaxes (e.g. list comprehensions), I was wondering what people thought about a similar thing with while. It might look something like:
>
> value = get_some_value() while value in undesired_values()
>
> Perhaps not this exact syntax though, as the parser might try to do `value = (get_some_value() while...)` instead of `(value = get_some_value) while...`.
>
> Other languages have features which allow something to look slightly less like this pattern, e.g. Java:
>
> SomeType value;
> while ((/* The assignment */ value = getSomeValue()) /* Compare */ == undesired_value) {}
>
> Granted, this isn't exactly tidy, but it's a little more DRY and, IMO, preferable.
>
> What are other's thoughts on this?
>
It won't happen as different format loops have been discussed and
rejected umpteen times over the last 20 odd years, mainly because the
code can be restructured using break as others have already pointed out.
Unless of course you fork Python, joining others working on variants
such as Python 2.8 or RickedPython :)
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Extension of while syntax Nelson Crosby <nc@sourcecomb.com> - 2014-12-11 18:21 -0800
Re: Extension of while syntax Ben Finney <ben+python@benfinney.id.au> - 2014-12-12 13:37 +1100
Re: Extension of while syntax Chris Angelico <rosuav@gmail.com> - 2014-12-12 13:38 +1100
Re: Extension of while syntax Marko Rauhamaa <marko@pacujo.net> - 2014-12-12 09:10 +0200
Re: Extension of while syntax Chris Angelico <rosuav@gmail.com> - 2014-12-12 18:38 +1100
Re: Extension of while syntax Marko Rauhamaa <marko@pacujo.net> - 2014-12-12 10:25 +0200
Re: Extension of while syntax cl@isbd.net - 2014-12-12 09:09 +0000
Re: Extension of while syntax Marko Rauhamaa <marko@pacujo.net> - 2014-12-12 12:33 +0200
RE: Extension of while syntax "Clayton Kirkwood" <crk@godblessthe.us> - 2014-12-11 18:59 -0800
Re: Extension of while syntax Terry Reedy <tjreedy@udel.edu> - 2014-12-11 22:00 -0500
Re: Extension of while syntax Ben Finney <ben+python@benfinney.id.au> - 2014-12-12 14:14 +1100
Re: Extension of while syntax Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-12-12 08:00 +0000
Re: Extension of while syntax Chris Angelico <rosuav@gmail.com> - 2014-12-12 19:05 +1100
Re: Extension of while syntax Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-12-12 11:38 -0500
Re: Extension of while syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-13 22:56 +1100
csiph-web