[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-ideas
Subject:    Re: [Python-ideas] an unless statement would occasionally be useful
From:       Neil Girdhar <mistersheik () gmail ! com>
Date:       2015-05-19 15:42:48
Message-ID: c290947c-85ea-433c-a8c4-9b7d9fd81ffe () googlegroups ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


This is hilarious.

Although to be fair, test might be useful if for example, you test types in 
one thread and run code optimized for that type in another…

On Sunday, May 17, 2015 at 5:40:59 PM UTC-4, Andrew Barnert via 
Python-ideas wrote:
>
> On May 17, 2015, at 11:07, Charles Hixson <charle...@earthlink.net 
> <javascript:>> wrote: 
> > 
> > I'm envisioning "unless" as a synonym for "if not(...):"  currently I 
> use 
> > 
> > if .... : 
> >    pass 
> > else: 
> >  ... 
> > 
> > which works. 
> > 
> > N.B.:  This isn't extremely important as there are already two ways to 
> accomplish the same purpose, but it would be useful, seems easy to 
> implement, and is already used by many other languages.  The advantage is 
> that when the condition is long it simplifies understanding. 
>
> But if you just use not instead of else, it simplifies understanding just 
> as much--and without making the language larger (which makes it harder to 
> learn/remember when switching languages, makes the parser bigger, etc.): 
>
>     if not ...: 
>         ... 
>
> It seems like every year someone proposes either "unless" or "until" or 
> the whole suite of Perl variants (inherently-negated keywords, postfix, 
> do...while-type syntax), but nobody ever asks for anything clever. Think of 
> what you could do with a "lest" statement, which will speculatively execute 
> the body and then test the condition before deciding whether to actually 
> have executed the body. Or a "without" that closes a context before the 
> body instead of after. Or a "butfor" that iterates over every extant object 
> that isn't contained in the Iterable. Or a "because" that raises instead of 
> skipping the body if the condition isn't truthy. Or a "before" that 
> remembers the body for later and executes it a synchronously when the 
> condition becomes true. 
>
>
>
> > _______________________________________________ 
> > Python-ideas mailing list 
> > Python...@python.org <javascript:> 
> > https://mail.python.org/mailman/listinfo/python-ideas 
> > Code of Conduct: http://python.org/psf/codeofconduct/ 
> _______________________________________________ 
> Python-ideas mailing list 
> Python...@python.org <javascript:> 
> https://mail.python.org/mailman/listinfo/python-ideas 
> Code of Conduct: http://python.org/psf/codeofconduct/ 
>

[Attachment #5 (text/html)]

<div dir="ltr">This is hilarious.<div><br></div><div>Although to be fair, test might \
be useful if for example, you test types in one thread and run code optimized for \
that type in another…<br><br>On Sunday, May 17, 2015 at 5:40:59 PM UTC-4, Andrew \
Barnert via Python-ideas wrote:<blockquote class="gmail_quote" style="margin: \
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On May 17, 2015, \
at 11:07, Charles Hixson &lt;<a href="javascript:" target="_blank" \
gdf-obfuscated-mailto="pR6ruZTWezAJ" rel="nofollow" \
onmousedown="this.href='javascript:';return true;" \
onclick="this.href='javascript:';return true;">charle...@earthlink.net</a>&gt; wrote: \
<br>&gt;  <br>&gt; I'm envisioning "unless" as a synonym for "if not(...):" \
&nbsp;currently I use <br>&gt; 
<br>&gt; if .... :
<br>&gt; &nbsp; &nbsp;pass
<br>&gt; else:
<br>&gt; &nbsp;...
<br>&gt; 
<br>&gt; which works.
<br>&gt; 
<br>&gt; N.B.: &nbsp;This isn't extremely important as there are already two ways to \
accomplish the same purpose, but it would be useful, seems easy to implement, and is \
already used by many other languages. &nbsp;The advantage is that when the condition \
is long it simplifies understanding. <br>
<br>But if you just use not instead of else, it simplifies understanding just as \
much--and without making the language larger (which makes it harder to learn/remember \
when switching languages, makes the parser bigger, etc.): <br>
<br>&nbsp; &nbsp; if not ...:
<br>&nbsp; &nbsp; &nbsp; &nbsp; ...
<br>
<br>It seems like every year someone proposes either "unless" or "until" or the whole \
suite of Perl variants (inherently-negated keywords, postfix, do...while-type \
syntax), but nobody ever asks for anything clever. Think of what you could do with a \
"lest" statement, which will speculatively execute the body and then test the \
condition before deciding whether to actually have executed the body. Or a "without" \
that closes a context before the body instead of after. Or a "butfor" that iterates \
over every extant object that isn't contained in the Iterable. Or a "because" that \
raises instead of skipping the body if the condition isn't truthy. Or a "before" that \
remembers the body for later and executes it a synchronously when the condition \
becomes true. <br>
<br>
<br>
<br>&gt; ______________________________<wbr>_________________
<br>&gt; Python-ideas mailing list
<br>&gt; <a href="javascript:" target="_blank" gdf-obfuscated-mailto="pR6ruZTWezAJ" \
rel="nofollow" onmousedown="this.href='javascript:';return true;" \
onclick="this.href='javascript:';return true;">Python...@python.org</a> <br>&gt; <a \
href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank" \
rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fma \
il.python.org%2Fmailman%2Flistinfo%2Fpython-ideas\46sa\75D\46sntz\0751\46usg\75AFQjCNFj1EaNHnVmh20FnFPoUi4J-MpfQw';return \
true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fmail.python.or \
g%2Fmailman%2Flistinfo%2Fpython-ideas\46sa\75D\46sntz\0751\46usg\75AFQjCNFj1EaNHnVmh20FnFPoUi4J-MpfQw';return \
true;">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a> <br>&gt; Code \
of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank" \
rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fpyth \
on.org%2Fpsf%2Fcodeofconduct%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHJOrArSUDKkjrnthO6_CznMzkPsA';return \
true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fpython.org%2Fpsf \
%2Fcodeofconduct%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHJOrArSUDKkjrnthO6_CznMzkPsA';return \
true;">http://python.org/psf/<wbr>codeofconduct/</a> \
<br>______________________________<wbr>_________________ <br>Python-ideas mailing \
list <br><a href="javascript:" target="_blank" gdf-obfuscated-mailto="pR6ruZTWezAJ" \
rel="nofollow" onmousedown="this.href='javascript:';return true;" \
onclick="this.href='javascript:';return true;">Python...@python.org</a> <br><a \
href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank" \
rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fma \
il.python.org%2Fmailman%2Flistinfo%2Fpython-ideas\46sa\75D\46sntz\0751\46usg\75AFQjCNFj1EaNHnVmh20FnFPoUi4J-MpfQw';return \
true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fmail.python.or \
g%2Fmailman%2Flistinfo%2Fpython-ideas\46sa\75D\46sntz\0751\46usg\75AFQjCNFj1EaNHnVmh20FnFPoUi4J-MpfQw';return \
true;">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a> <br>Code of \
Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank" \
rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fpyth \
on.org%2Fpsf%2Fcodeofconduct%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHJOrArSUDKkjrnthO6_CznMzkPsA';return \
true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fpython.org%2Fpsf \
%2Fcodeofconduct%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNHJOrArSUDKkjrnthO6_CznMzkPsA';return \
true;">http://python.org/psf/<wbr>codeofconduct/</a> <br></blockquote></div></div>



_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic