[Python-ideas] Verbatim names (allowing keywords as names)

Eric V. Smith eric at trueblade.com
Wed May 16 04:56:22 EDT 2018

On 5/16/18 4:47 AM, Eric V. Smith wrote:
> On 5/16/18 4:13 AM, Paul Moore wrote:

>> Can you give a worked example of how this would
>> help if we wanted to introduce a new keyword? For example, if we
>> intended to make "where" a keyword, what would numpy and its users
>> need to do to continue using `numpy.where`?
> I think they'd have to change to `numpy.\where` when `where` became a
> keyword.

To be clear: this would apply to any code that uses numpy.where, not 
just the code that defines it.

The only way to bullet-proof your code so that it would never need any 
modifications in the future would be to put a backslash in front of 
every identifier. Or maybe just all-lowercase identifiers, since we're 
unlikely to make a keyword with uppercase chars in it.

And since no one in their right mind would do that, there's still the 
risk of your code breaking in the future. But at least there would be a 
way of fixing it in a way that would work both with old versions of 
python where the identifier isn't a keyword, and for versions where it 
is. That is, once "old versions" include ones that support verbatim names.


More information about the Python-ideas mailing list