What is your experience porting Python 2.7.x scripts to Python 3.x?

Cameron Simpson cs at cskk.id.au
Wed Jan 23 15:22:53 EST 2019


On 23Jan2019 14:15, Grant Edwards <grant.b.edwards at gmail.com> wrote:
>On 2019-01-22, Cameron Simpson <cs at cskk.id.au> wrote:
>> On 22Jan2019 19:20, Grant Edwards <grant.b.edwards at gmail.com> wrote:
>>>On 2019-01-22, Schachner, Joseph <Joseph.Schachner at Teledyne.com> wrote:
>>>> For anyone who has moved a substantial bunch of Python 2 to Python
>>>> 3, can you please reply with your experience?
>>>
>>>If you used bytes (or raw binary strings) at all (e.g. for doing
>>>things like network or serial protocols) you're in for a lot of pain.
>>
>> Yes, but you will be the better for it afterwards.
>
>It's a lot better if you're leaving Python2 behind.  If you're
>maintaing 2/3 compatible code that uses bytes, the pain is chronic
>rather than acute.

Um, yes, very true.

>> I've had a few programs which worked with binary data, and often
>> also "text". In Python 2 there was _constant_ uncertanty when these
>> were mixed (writing text into binary fields and related). In Python
>> 3 I am never confused. It is a huge win.
>
>For whatever reason, I guess I never ran into that very much.

The instance I have in mind was a fairly complex bit of code doing lots 
of binary and also strings in Python 2. It is now Python 3 only and far 
cleaner. As as you suggest, _not_ Python 2 compatible.

Cheers,
Cameron Simpson <cs at cskk.id.au>



More information about the Python-list mailing list