[issue7141] 2to3 should add from __future__ import print_statement

Daniel Stutzbach report at bugs.python.org
Tue Aug 31 23:53:24 CEST 2010


Daniel Stutzbach <daniel at stutzbachenterprises.com> added the comment:

I don't think I'm familiar enough with 2to3's pattern-matching syntax to write a good patch.

Here's a rough outline for how a patch would work.  There are two cases: 

1) When there is already a "from __future__ import".  Currently, this line is stripped by fix_future.  fix_future could be changed to remove the other futures, but add/leave "print_statement".  This case is probably pretty straightforward.

2) When there is no "from __future__ import".  A pattern would need to detect the absence of the __future__ line and insert one in the right place (after initial comments but before anything else).

----------
stage:  -> needs patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7141>
_______________________________________


More information about the Python-bugs-list mailing list