Moving from Python 2 to Python 3: A 4 page "cheat sheet"

John Posner jjposner at optimum.net
Wed Dec 2 11:41:32 EST 2009


On Wed, 02 Dec 2009 10:55:23 -0500, Mark Summerfield <list at qtrac.plus.com>  
wrote:

> On Dec 1, 2:03 pm, Mark Summerfield <l... at qtrac.plus.com> wrote:
>> I've produced a 4 page document that provides a very concise summary
>> of Python 2<->3 differences plus the most commonly used new Python 3
>> features. It is aimed at existing Python 2 programmers who want to
>> start writing Python 3 programs and want to use Python 3 idioms rather
>> than those from Python 2 where the idioms differ.

Mark, I add my thanks to those of the other responders. If you find space,  
you might consider adding another str.format() feature:

  Goal: place integer 456 flush-right in a field of width 8

   Py2: "%%%dd" % 8 % 456
   Py3: "{0:{1}d}".format(456, 8)

With str.format(), you don't need to nest one formatting operation within  
another. A little less mind-bending, and every little bit helps!

-John



More information about the Python-list mailing list