[Python-ideas] add a single __future__ for py3?
chris.barker at noaa.gov
Tue Sep 22 00:03:41 CEST 2015
On Sat, Sep 19, 2015 at 11:21 AM, Brett Cannon <brett at python.org> wrote:
> It would be nice to have a:
>> from __future__ import py3
> 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.
That may well kill the idea then, yes.
> It's just about these four imports, right?
> from __future__ import absolute_import
> from __future__ import division
> from __future__ import print_function
> from __future__ import unicode_literals
yup, but that is enough to be a able to remember and type...
and will there be more? probably not, but .....
But you are right, if we can redude that to a couple, maybe a smaller deal.
> I think the case is overblown.
> - absolute_import is rarely an issue; the only thing it does (despite the
> name) is give an error message when you attempt a relative import without
> using a "." in the import. A linter can find this easily for you, and a
> little discipline plus the right example can do a lot of good here.
sure -- but this one is more for the learners -- these things are confusing
-- and getting something that works in one version of python but not
another will be more confusing, still.
And much as I wish everyone would use a good linter....
> - division is important.
> - print_function is important.
so maybe those two are enough....
> - unicode_literals is useless IMO. It breaks some things (yes there are
> still APIs that don't take unicode in 2.7) and it doesn't nearly as much as
> what would be useful -- e.g. repr() and <stream>.readline() still return
> 8-bit strings. I recommend just using u-literals and abandoning Python 3.2.
hmm -- I find myself doing an unholy mess of u"" and "". And I tried
teaching an intro class where I used u"" everywhere -- the students were
pretty confused about why they were typing all those u-s, particularly
since it didn't seem to make any difference.
Sure there is breakage, but there is breakage on some of these between py2
and py3 anway -- APIs that return py2 strings on py2... So unicode_literals is
still useful to me.
But Brett was probably right -- somethign minor but useful but only works
on the very latest bug-fix release is probably an attractive nuisance more
than anything else.
Christopher Barker, Ph.D.
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas