Why do future_statements in Python need to be placed before everything? -


pep 236 states future_statements must appear near top of module, comments, docstrings , allowed before them.

i understand isn't debatable programming practice - it's rules , they're clear. however, can't google myself answer why decided error rather violation of recommended practices when fail place future_statement @ top (aka, warning).

is because way, modules import own versions of names future_statement import, able override them, ensuring they'll work correctly? maintain sort of strong code clarity proper coding practices aren't broken because of potential disasters if __future__ import accidentally ignored? pep isn't enlightening on , can't leads finding out why.

__future__ statements potentially have effects on parsing (example: unicode_literals, print_function), may modify (or rather switch different version of) grammar. must known possible. have effects on code generation (division).

there are design reasons force statements @ start of parsing , compilation, in addition clarity concerns.

other imported modules not have effect on going on in your module respect __future__. thing, because otherwise other modules break module importing print_function __future__.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -