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

Chris Barker chris.barker at noaa.gov
Thu May 17 13:10:10 EDT 2018


On Wed, May 16, 2018 at 2:09 PM, Carl Smith <carl.input at gmail.com> wrote:

> If your position is that Guido shouldn't introduce keywords that are
> currently used as names at all,
>

Exactly -- which is why I'm wondering my no one (that I've seen -- long
thread)  is presenting the backwards option:

Any new keywords introduced will be non-legal as regular names.

\new_key_word

for instance.

Makes me think that it may have been good to have ALL keywords somehow
non-legal as user-defined names -- maybe ugly syntax, but it would make a
clear distinction.

how ugly would this be?

\for i in range(n):
    \while \True:
        ...

pretty ugly :-(

But maybe not so much if only a handful of new ones....

Or is there another currently illegal character that could be used that
would be less ugly?

I'm actually confused as to what the point is to the \ prefix idea for
names:

* It would still require people to change their code when a new keyword was
introduced

* It would be no easier / harder than adding a conventional legal character
-- trailing underscore, or ???

* but now the changed code would no longer run on older versions of python.

I guess it comes down to why you'd want to call out:

"this is a name that is almost like a keyword"

Seems like a meh, meh, lose proposal to me.

OK, I see one advantage -- one could have code that already has BOTH word
and word_ names in it. So when word becomes a keyword, a tool that
automatically added an underscore would break the code. whereas if it
automatically added an currently illegal character, it wouldn't shadow
anything.

But a sufficiently smart tool could get around that, too.

-CHB


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180517/68bb6a57/attachment.html>


More information about the Python-ideas mailing list