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

Ethan Furman ethan at stoneleaf.us
Wed May 16 00:03:34 EDT 2018


On 05/15/2018 08:03 PM, Carl Smith wrote:
> On Tue, May 15, 2018 at 8:41 PM, Steven D'Aprano wrote:

>> I'd like to suggest we copy C#'s idea of verbatim identifiers, but using
>> a backslash rather than @ sign:
>>
>>      \name
>>
>> would allow "name" to be used as an identifier, even if it clashes with
>> a keyword.
>
> I strongly disagree, but can't seem to get anyone  to bite.

Sometimes it's like that, and yes it is frustrating.

> We want to be able to introduce a keyword that was formally a name, still
> allow
> it to be used as a name, still allow code that uses it as a keyword to
> interoperate
> ​ ​
> with code that uses it as a name, without changing the language
> or implementation  too much.
>
> ​Ideally, Python would still not allow the keyword to be used as a name and a
> keyword in the same file??

For me at least, this is a deal breaker.  My libraries tend to be single-file packages, so all my code is in one place 
-- only being able to use the keyname as one or the other in my multi-thousand line file does me no good.

--
~Ethan~


More information about the Python-ideas mailing list