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


Groups > comp.lang.python > #49079

Re: Is this PEP-able? fwhile

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <fabiosantosart@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
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; '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; 'thanks.': 0.20; 'portion': 0.22; 'cc:addr:python.org': 0.22; 'effort.': 0.24; "shouldn't": 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'message- id:@mail.gmail.com': 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; 'received:google.com': 0.35; 'there': 0.35; 'keyword': 0.36; 'much.': 0.36; 'possible': 0.36; 'so,': 0.37; 'too': 0.37; 'being': 0.38; 'pm,': 0.38; 'aspects': 0.39; 'bad': 0.39; 'itself': 0.39; 'sure': 0.39; 'subject:? ': 0.60; 'affect': 0.61; 'new': 0.61; 'course': 0.61; 'making': 0.63; 'act': 0.63; 'name': 0.63; 'for:': 0.64; 'teaching': 0.64; 'taking': 0.65; 'great': 0.65; 'to:addr:aol.com': 0.68; 'overall': 0.69; 'as:': 0.81; 'subject:this': 0.83; "'and'": 0.84; "'for'": 0.84; 'concept.': 0.84; 'costs,': 0.91; 'obvious,': 0.91; 'taught': 0.96; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=vuEw9fT0MJOQMj82WLe3o6jPwsDBXfi+WSi32tQ9lK8=; b=SoRD+c7a3K9/Yi+8I7e4YqxuHJGmqFdHQtmdXfQ4Yi7thnK0T3POrjbd+iI5sru04a TUWJhGlpfVxHCdBvziFCO1tQE/VRb7N8W+8WjPv0Skr4IXKLRVjxuP+4Dg6AmyaO2VIp LqDCAKdHq+5hyQpVZbx4ccNyIlJhAqvoBpHNhQDEnh7ikMU40FlClI/sAzp/4QVaU4xv pO01i+TKax10cXUx409rJo5d4GIQsUKdKcqlD7wv87MnLhwuj0LVwetRYrzx3ucKrtZr +OrKVCSohf8q6u2rnKW/Ohe67a5FW8eg7GOEV/3tFYp8oZJVnSz3APFwpqxsr+0RLJD0 CfCQ==
MIME-Version 1.0
X-Received by 10.224.161.145 with SMTP id r17mr29051554qax.72.1372106051841; Mon, 24 Jun 2013 13:34:11 -0700 (PDT)
In-Reply-To <8D03F2B8CF0E7BE-1864-1796B@webmail-m103.sysops.aol.com>
References <8D03F2B8CF0E7BE-1864-1796B@webmail-m103.sysops.aol.com>
Date Mon, 24 Jun 2013 21:34:11 +0100
Subject Re: Is this PEP-able? fwhile
From Fábio Santos <fabiosantosart@gmail.com>
To jimjhb@aol.com
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc "python-list@python.org" <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.3764.1372106054.3114.python-list@python.org> (permalink)
Lines 73
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1372106054 news.xs4all.nl 15978 [2001:888:2000:d::a6]:52054
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:49079

Show key headers only | View raw


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 Fábio Santos <fabiosantosart@gmail.com> - 2013-06-24 21:34 +0100

csiph-web