[Python-ideas] An alternative to PEP 572's Statement-Local Name Bindings

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Mar 3 18:58:14 EST 2018


Nathan Goldbaum wrote:
> Where is also very common in numpy. So if someone did:
> 
> from numpy import *
> 
> data = where(condition)
> 
> They might have issues

Bummer, I didn't know numpy used it. That puts rather a big
dampener on the idea of making it a keyword. :-(

Remaining options include:

* Make it a keyword only in certain contexts. That's been
done before, but only as a temporary measure. Making it a
permanent feature seems a bit hackish, and could cause
problems for syntax highlighters.

* Pick another word that isn't used often. My next choice
would be "given", with maybe "letting" as a distant third.
(Not just "let", because it doesn't read right after the
expression.)

* Re-use another keyword. Here "with" seems to be the best
choice, but that would entail giving it two wildly different
meanings. Guido probably isn't going to like that, since he
has already expressed disapproval of doing it with "for".

<tangential_ramble>

Some people thought Wirth was mad when he made all the
keywords in Modula upper-case, but maybe he knew a thing
or two.

Going back further, Algol required all keywords to be
marked specially in some way (that was left up to the
implementation).

If I ever design another language, I think I'm going to
require the source to be HTML, and insist that all
keywords be <b>bold</b>.

</tangential_ramble>

-- 
Greg


More information about the Python-ideas mailing list