[Python-ideas] Crazy idea: allow keywords as names in certain positions

Nick Coghlan ncoghlan at gmail.com
Mon May 14 00:36:11 EDT 2018


On 13 May 2018 at 14:19, Guido van Rossum <guido at python.org> wrote:

> As anyone still following the inline assignment discussion knows, a
> problem with designing new syntax is that it's hard to introduce new
> keywords into the language, since all the nice words seem to be used as
> method names in popular packages. (E.g. we can't use 'where' because
> there's numpy.where
> <https://docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.where.html>,
> and we can't use 'given' because it's used in Hypothesis
> <http://hypothesis.readthedocs.io/en/latest/quickstart.html>.)
>
> The idea I had (not for the first time :-) is that in many syntactic
> positions we could just treat keywords as names, and that would free up
> these keywords.
>

While I think the "restricted use" idea would be confusing, I do like the
idea of separating out "postfix keywords", which can't start a statement or
expression, and hence can be used *unambiguously* as names everywhere that
names are allowed.

Adding such a capability is essential to proposing a keyword based approach
to inline assignments, and would technically also allow "and", "or", "is",
and "as" to be freed up for use as names.

Cheers,
Nick.

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


More information about the Python-ideas mailing list