A counter-proposal to __future__ in PEP 236
Martin von Loewis
loewis at informatik.hu-berlin.de
Fri Mar 2 13:27:37 CET 2001
Joshua Marshall <jmarshal at mathworks.com> writes:
> > In this implementation, directive is only considered as a keyword if
> > it appears at the beginning of the module. Therefore, code that
> > happens to use directive as an identifier will not break (unless it
> > assigns to directive as the first thing in the module).
> Note that it doesn't need to be implemented this way. Currently,
> directive foo
> is a syntax error. Meaning can be assigned to this syntax without
> breaking any existing code--it is unambiguous.
Yes, but that is harder to implement - it requires a look-ahead for
the next token. Traditionally, Python has the notion of 'reserved
words' (aka keywords). 'directive' in above statement would be a
keyword - if it was a name, it won't parse.
Allowing a 'name name atom' production probably introduces a
grammatical ambiguity for the simple recursive-descent parser used in
Python. Classifying directive as a keyword only if it is followed by a
name is more than the classify function can do. If it is considered
necessary to break absolutely no code, I could look into implementing
it that way.
More information about the Python-list