Chris Angelico rosuav at gmail.com
Mon Feb 15 21:30:14 EST 2016

On Tue, Feb 16, 2016 at 1:02 PM, Rick Johnson
<rantingrickjohnson at gmail.com> wrote:
>> But once that happened, I moved from Py2 to Py3 years ago
>> with scarcely a bump, bruise, or scratch.
> So you have no Python2.x code remaining in your repos? Are
> you telling us that you moved *EVERYTHING* to Python3? If
> so, i can't imagine how something like that would even be
> possible, hmm, unless of course, you don't have much code to
> move...?

I have one project that's bound to Py2 by its one dependency, and I've
kept it Py3-compatible apart from the one block of code that sets that
up. (That includes renaming a function that was originally called
"await", even though that's not actually a keyword as of 3.6.) All the
rest of my code will run on Python 3. However, there is still a lot of
Python 2 code in my repos - it's the same code! Most of my stuff is
simple enough that I keep it 2/3 compatible. Sometimes there's a block
of code at the top to deal with {raw_,}input or a future directive or
a changed import name, but the bulk of the code is unchanged.

Of course, now that I go to actually *check*, it turns out that a lot
of my code has accidentally not been cross-version compatible. I use
the open(fn, encoding="...") form in quite a few places, so to make
that work, I would need "from io import open" (which seems to be a
safe no-op on Py3), and there are places where I use multi-arg
versions of print, which will end up displaying tuples in Py2 if I
don't slap in a __future__ directive. But that just means that I
really truly have *moved* to Python 3, to the extent that I don't
always even test my code on 2.7 any more.


More information about the Python-list mailing list