On Wed, 16 May 2018 09:13:52 +0100
Paul Moore <p.f.mo...@gmail.com> wrote:
> On 16 May 2018 at 01:41, Steven D'Aprano <st...@pearwood.info> wrote:
> > Inspired by Alex Brault's  post:
> >
> > https://mail.python.org/pipermail/python-ideas/2018-May/050750.html
> >
> > 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'm missing something. How is that different from using a trailing
> underscore (like if_ or while_) at the moment? I understand that foo
> and \foo are the same name, whereas foo and foo_ are different, but
> how would that help?

I think it could help in cases like namedtuple, where names can be
part of a data description (e.g. coming from a database) and then used
for attribute access.  I do not find it extremely pretty, but I like it
much better still than the "allowing keywords as names" proposal.

It also has the nice side-effect that it doesn't make it easier to add
new keywords, since the common spelling (e.g. `np.where`) would still
become a syntax error and therefore break compatibility with existing
code.

Regards

Antoine.


_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to