[Python-ideas] add a single __future__ for py3?

Brett Cannon brett at python.org
Sat Sep 19 20:21:48 CEST 2015


On Sat, 19 Sep 2015 at 10:51 Chris Barker <chris.barker at noaa.gov> wrote:

> Hi all,
>
> the common advise, these days, if you want to write py2/3 compatible code,
> is to do:
>
> from __future__ import absolute_import
> from __future__ import division
> from __future__ import print_function
> from __future__ import unicode_literals
>
>
> https://docs.python.org/2/howto/pyporting.html#prevent-compatibility-regressions
>
> I'm trying to do this in my code, and teaching my students to do it to.
>
> but that's actually a lot of code to write.
>
> It would be nice to have a:
>
> from __future__ import py3
>
> or something like that, that would do all of those in one swipe.
>
> IIIC, l can't make a little module that does that, because the __future__
> imports only effect the module in which they are imported
>
> Sure, it's not a huge deal, but it would make it easier for folks wanting
> to keep up this best practice.
>
> Of course, this wouldn't happen until 2.7.11, if an when there even is
> one, but it would be nice to get it on the list....
>
>
While in hindsight having a python3 __future__ statement that just turned
on everything would be handy, this runs the risk of breaking code by
introducing something that only works in a bugfix release and we went down
that route with booleans in 2.2.1 and came to regret it.

-Brett



> -Chris
>
>
>
>
> --
>
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> Chris.Barker at noaa.gov
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150919/548d11b3/attachment.html>


More information about the Python-ideas mailing list