On 20 September 2016 at 08:57, אלעזר <elaz...@gmail.com> wrote:
> This is since in Python there are no contextual keywords (like "override"
> and "final" in C++). I remember encountering error in a Django project where
> accessing u.pass was a syntax error, but there *was* a field "pass" in u and
> they had to resort to getattr(u, "pass").
> What is the reasoning behind that decision?

Python's grammar is deliberately not context sensitive, as that makes
it easier to parse (for both humans and computers). In particular,
this means that things *other* than the Python interpreter can parse
Python easily (think editor syntax highlighting, linters, etc). There
have been occasional deviations from this (for example, the "as" in
"import foo as bar" was, for a time, only a keyword in that specific
context) but I don't believe any of them survived long-term.

Guido has always avoided constructs that need lookahead or other
contextual information to parse correctly, for this specific reason.
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/

Reply via email to