> >> It would be a bear to implement error handling for cases like > >> this: > >> > >> from __future__ import a; import b; from __future__ import c > > GvR> Really?!? Why? Isn't it straightforward to check that > GvR> everything you encounter in a left-to-right leaf scan of the > GvR> parse tree is either a future statement or a docstring until > GvR> you encounter a non-future? > > It's not hard to find legal future statements. It's hard to find > illegal ones. The pass to find future statements exits as soon as it > finds something that isn't a doc string or a future. The symbol table > pass detects illegal future statements by comparing the current line > number against the line number of the last legal futre statement. Aha. That's what I missed -- comparison by line number. One thing you could do would simply be check the entire current simple_statement, which would catch the above example; the possibilities are limited at that level (no blocks can start on the same line after an import). --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4