[Python-ideas] Verbatim names (allowing keywords as names)
Carl Smith
carl.input at gmail.com
Wed May 16 14:20:35 EDT 2018
> There can be 2 escape characters '\' and '.'
That's clever, but then we have to put a slash in front of names in
imports, assignments and keyword arguments, but not properties.
-- Carl Smith
carl.input at gmail.com
On 16 May 2018 at 19:17, Carl Smith <carl.input at gmail.com> wrote:
> > Not if you need to make changes in the same tens of thousands of lines
> file.
>
> But what has that got to do with the the syntax of the new code? The old
> code is
> what it is.
>
> I did think after I replied that `True` wasn't actually reserved until
> more recently, but
> the point still stands: You would be able to reference the name *as
> defined* in an
> external library, and yeah, it could refer to anything, but that's kinda
> the point. We
> have to assume the library does something sane with the name. We can't
> preempt
> an employee sabotaging `True`.
>
> As a more realistic example (if not for Python), say `until` became a
> keyword, then
> you could end up with lines like this:
>
> from oldlib import until as upto
>
> dance(until="am")
>
> event.until = time(9, 30)
>
> > The overall issue is that python has no way of knowing if the keyword
> is being used for legitimate
> > backwards-compatibility purposes or someone intentionally overrode after
> it was made a keyword
> > because they somehow thought it was a good idea.
>
> I only said that Python does not know *until runtime*, and I was wrong
> when I described that as a
> problem. A runtime NameError actually makes perfect sense. Assigning to `self.until`
> or assigning
> to `until` inside a subclass should not be a syntax error. A NameError
> would be correct.
>
> It worth mentioning that the cost of checking only applies to cases where
> the name in question is also
> keyword, so almost never.
>
>
> -- Carl Smith
> carl.input at gmail.com
>
> On 16 May 2018 at 16:40, Niki Spahiev <niki.spahiev at gmail.com> wrote:
>
>> On 16.05.2018 16:05, Andrés Delfino wrote:
>>
>>> IMHO, it would be much easier to learn and understand if keywords can
>>> only
>>> be used by escaping them, instead of depending where they occur.
>>>
>>
>> There can be 2 escape characters '\' and '.'
>>
>> Niki
>>
>>
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> https://mail.python.org/mailman/listinfo/python-ideas
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180516/fb348d2d/attachment.html>
More information about the Python-ideas
mailing list