[Python-ideas] relaxing keyword usage restrictions

H Krishnan hetchkay at gmail.com
Mon Sep 5 06:55:10 CEST 2011


Apologies if this has been asked already: why can't the usage of at
least some keywords as identifiers be allowed with the context of the
usage being used to identify if a keyword or a variable is being
referred to.

For example,

if = 3  # if is identifier
if if = 3: # first if is keyword, second if is identifer

A more complex usage may require some rules:

a = not or and and
==> parse left to right to interpret as a = ( (not or) and (and) ).
'or' and the last 'and' are identifiers

While some of the usage may be confusing to the user, that is not for
the language to dictate but for the user to choose.

Almost all keywords have specific semantics which (in my limited
understanding) do not conflict with their usage as identifiers.


More information about the Python-ideas mailing list