Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49083

Re: Is this PEP-able? fwhile

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jimjhb@aol.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; '(at': 0.04; 'syntax': 0.04; 'python)': 0.05; 'indexing': 0.07; 'subject:PEP': 0.07; 'welcome.': 0.07; 'check,': 0.09; 'happen.': 0.09; 'idea?': 0.09; 'cc:addr:python-list': 0.11; 'email addr:python.org&gt;': 0.11; 'python': 0.11; 'language,': 0.12; '"and"': 0.16; "'break'": 0.16; "'for',": 0.16; '(note:': 0.16; '24,': 0.16; 'devs': 0.16; 'keyword,': 0.16; 'syntax,': 0.16; 'true:': 0.16; 'language': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'message-----': 0.19; 'thanks.': 0.20; 'email addr:gmail.com&gt;': 0.22; 'portion': 0.22; 'cc:addr:python.org': 0.22; 'effort.': 0.24; "shouldn't": 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '&gt;': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; "i'm": 0.30; 'code': 0.31; 'comments': 0.31; 'argue': 0.31; 'motivation': 0.31; 'probably': 0.32; 'themselves': 0.32; 'run': 0.32; 'sense': 0.34; 'maybe': 0.34; 'could': 0.34; 'convert': 0.35; 'etc.)': 0.35; 'but': 0.35; 'there': 0.35; 'keyword': 0.36; 'much.': 0.36; 'possible': 0.36; 'so,': 0.37; 'too': 0.37; 'being': 0.38; 'skip:- 10': 0.38; 'pm,': 0.38; 'subject:': 0.39; 'aspects': 0.39; 'bad': 0.39; 'itself': 0.39; 'sure': 0.39; 'subject:? ': 0.60; 'from:no real name:2**0': 0.61; 'affect': 0.61; 'new': 0.61; 'course': 0.61; 'making': 0.63; 'header:Message-Id:1': 0.63; 'act': 0.63; 'name': 0.63; 're:': 0.63; 'for:': 0.64; 'teaching': 0.64; 'taking': 0.65; 'great': 0.65; 'to:addr:gmail.com': 0.65; 'overall': 0.69; 'as:': 0.81; 'subject:this': 0.83; "'and'": 0.84; "'for'": 0.84; 'concept.': 0.84; 'received:64.12.224': 0.84; 'costs,': 0.91; 'obvious,': 0.91; 'taught': 0.96; '2013': 0.98
References <8D03F2B8CF0E7BE-1864-1796B@webmail-m103.sysops.aol.com> <CAA=1kxR65wqgQWQJaLvP2yx_XacEMsHiFs40rPW1UbFXYpnytA@mail.gmail.com>
To fabiosantosart@gmail.com
Subject Re: Is this PEP-able? fwhile
In-Reply-To <CAA=1kxR65wqgQWQJaLvP2yx_XacEMsHiFs40rPW1UbFXYpnytA@mail.gmail.com>
X-MB-Message-Source WebUI
MIME-Version 1.0
From jimjhb@aol.com
X-MB-Message-Type User
Content-Type multipart/alternative; boundary="--------MB_8D03F33106267B1_1864_5862E_webmail-m103.sysops.aol.com"
X-Mailer AOL Webmail 37834-STANDARD
X-Originating-IP [208.67.228.35]
Date Mon, 24 Jun 2013 16:46:41 -0400 (EDT)
x-aol-global-disposition G
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=mx.aol.com; s=20121107; t=1372106801; bh=7bk9Wp5YKKS/oOpFGULuPo9cT8x61n331goQj+2tlH0=; h=From:To:Subject:Message-Id:Date:MIME-Version:Content-Type; b=SfXcqrewg/DTPYf9SfQcuhi0tjPrh/Z+2H/lzGcqXFNd5nXmVNOZgMuizJ4bAQjWA tc9qo6OiF68jfTioTjge7xJpW01AZwzCEjWHfIzOWhfV+OD5aFGPVpWK5hgq4ZIJ8p 67vU5pW/u8figHPXEJWqwpEpgoP1OS+Wqzc0rsvs=
X-AOL-SCOLL-SCORE 0:2:431122688:93952408
X-AOL-SCOLL-URL_COUNT 0
x-aol-sid 3039ac1d33c951c8b0311341
Cc python-list@python.org
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3768.1372107124.3114.python-list@python.org> (permalink)
Lines 207
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1372107124 news.xs4all.nl 15885 [2001:888:2000:d::a6]:40694
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:49083

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Your syntax makes great sense.  Avoiding new keywords is obviously preferable.



-----Original Message-----
From: Fábio Santos <fabiosantosart@gmail.com>
To: jimjhb <jimjhb@aol.com>
Cc: python-list <python-list@python.org>
Sent: Mon, Jun 24, 2013 4:34 pm
Subject: Re: Is this PEP-able? fwhile


On Mon, Jun 24, 2013 at 8:52 PM,  <jimjhb@aol.com> wrote:
> Syntax:
>
> fwhile X in ListY and conditionZ:
>
> The following would actually exactly as:  for X in ListY:
>
> fwhile X in ListY and True:
>
> fwhile would act much like 'for', but would stop if the condition after the
> 'and' is no longer True.
>
> The motivation is to be able to make use of all the great aspects of the
> python 'for' (no indexing or explict
> end condition check, etc.) and at the same time avoiding a 'break' from the
> 'for'.
>
> (NOTE:  Many people are being taught to avoid 'break' and 'continue' at all
> costs, so they instead convert
> the clean 'for' into a less-clean 'while'.  Or they just let the 'for' run
> out.  You can argue against this teaching
> (at least for Python) but that doesn't mean it's not prevalent and
> prevailing.)
>
> [People who avoid the 'break' by functionalizing an inner portion of the
> loop are just kidding themselves and making
> their own code worse, IMO.]
>
> I'm not super familiar with CPython, but I'm pretty sure I could get this up
> and working without too much effort.
> The mandatory 'and' makes sense because 'or' would hold the end value valid
> (weird) and not accomplish much.
> The condition itself could of course have multiple parts to it, including
> 'or's.
>
> It's possible the name 'fwhile' is not optimal, but that shouldn't affect
> the overall merit/non-merit of the concept.
>
> Comments and Questions welcome.
>
> Thanks.
>

I can see where you are coming from, but this is probably not going to
happen.  The "and" keyword is also

Also, the (amazing) python devs are concerned with overcomplicating
the language syntax, which is bad for: newbies, other implementations
of the language, and code readability. The syntax doesn't seem too
obvious, and there is a new keyword, "fwhile".

This can probably be best achieved by adding to the existing for loop,
so maybe taking advantage of the existing for...if syntax and adding
for...while would be a better idea?

So, maybe:

for x in y while cond:

And for list/set/dict comprehensions and generator expressions:

[x for x in range(123) while cond]

Just maybe.

--
Fábio Santos

 

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Is this PEP-able? fwhile jimjhb@aol.com - 2013-06-24 16:46 -0400

csiph-web