[Python-ideas] Python-ideas Digest, Vol 138, Issue 32

Nick Coghlan ncoghlan at gmail.com
Sat May 5 20:36:03 EDT 2018

On 6 May 2018 at 07:59, Angus Hollands <goosey15 at gmail.com> wrote:

> If, however, the motivation for the PEP was deemed significant enough that
> warrant its inclusion in a future release, then I would like to suggest
> that the keyword approach is superior to the operator variant. In
> particular, I prefer the `where` to the `given` or 'let' candidates, as I
> think it is more descriptive and slightly shorter to type ;)

Aside from an API naming conflict with NumPy, the key problem with using
"where" for this purpose is that "where" is explicitly used to name
*filtering* clauses in SQL, NumPy, and other contexts ("having" is used in
a similar way for filtering on SQL aggregate groups). So in "[(x, y, x/y)
for x in data if y where y = f(x)]", having both an "if" clause and a
"where" clause makes it look like there are two filters being defined (and
a mispelt "==" in the second one), rather than a filter and a name binding.

The virtue of "given" is that in any context which uses it, the intended
meaning is to associate a name with a value (either directly, as in the
mathematical usage, or indirectly, as in the hypothesis API usage), which
is exactly the meaning we're interested in here.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180506/4c159638/attachment.html>

More information about the Python-ideas mailing list