[Python-ideas] Suggestion: Clear screen command for the REPL
Paul Moore
p.f.moore at gmail.com
Tue Sep 20 04:20:00 EDT 2016
On 20 September 2016 at 08:57, אלעזר <elazarg at 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
More information about the Python-ideas
mailing list