On 6 May 2018 at 07:59, Angus Hollands <[email protected]> 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.

Cheers,
Nick.

-- 
Nick Coghlan   |   [email protected]   |   Brisbane, Australia
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to