[Python-ideas] Syntactic Sugar: Post-Conditions for Guard Clauses
Chris Barker
chris.barker at noaa.gov
Thu May 17 16:18:59 EDT 2018
On Thu, May 17, 2018 at 12:55 PM, Manuel Barkhau <mbarkhau at gmail.com> wrote:
> continue if not is_valid(elem)
> ...
>
how is this better than:
if not is_valid(elem):
continue
?
But even if it is, that might be a consideration for a new language, but
adding it to python now is pretty darn unlikely.
> When there is an expression involved for the case of a `return`
> or `raise` statement, I don't think it's such a great style,
> because the conditional gets hidden off to the right.
>
now I"m confused -- if it's not a great sytle, why suggest it?
and I was thinking that the one good thing is that the "return" or "break"
is a bit more prominent -- which could be a good thing.
Alternatively, is there a good way I can implement this as a
> preprocessor for myself?
>
I'm pretty sure not -- python is very dynamic, but not let you redefine the
language semantics.
Other than as a import hook that re-wrote the code on the fly.
but really -- don't do that -- then no one else will understand your code.
-CHB
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180517/6f603981/attachment.html>
More information about the Python-ideas
mailing list