Hi all, One problem already alluded to with the \identifier syntax is that it only works if the old Python version is sufficiently recent to understand \.
What about using parentheses to allow a keyword to be used as an identifier: (where)(x, y) This then in combination with allowing keywords in the following unambiguous locations: 1. After dot ("numpy.where") 2. After def and class ("def where") 3. After "as". This should make it possible to write code which works in a hypothetical future Python version where "where" is a keyword, and which also works with current Python versions. Stephan 2018-05-16 11:03 GMT+02:00 Paul Moore <p.f.mo...@gmail.com>: > On 16 May 2018 at 09:56, Eric V. Smith <e...@trueblade.com> wrote: > > 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. > > That's about what I thought - thanks. > Paul > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/