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

Wolodja Wentland wentland at cl.uni-heidelberg.de
Wed Dec 2 06:20:33 EST 2009


On Wed, Dec 02, 2009 at 00:10 -0800, Mark Summerfield wrote:
> On 1 Dec, 18:30, Lie Ryan <lie.1... at gmail.com> wrote:

> > Also, I'm not sure what this change is referring to:
> > Python 2                 Python 3
> > L = list(seq)            L = sorted(seq)
> > L.sort()
> >
> > L.sort is still available in python, and sorted() have been available
> > since python 2. Both list.sort() and sorted() are for different purpose,
> > and neither will be deprecated. What's the change here?
> 
> The document is about idioms as well as changes. In this case both
> approaches work in both versions, but it seems that there are still a
> lot of people who don't know about sorted(), so I put it in to show it
> as an idiom.

It would be quite nice if you could mark all the Python 3 idioms that
work in Python 2.X as well. This would allow readers that are still using
Python 2.X and are used to the 'old way' to adapt their coding style
accordingly. You could just add a little (2.X) after the idiom for
example.

And thanks for the nice cheat sheet! :-D

-- 
  .''`.     Wolodja Wentland    <wentland at cl.uni-heidelberg.de> 
 : :'  :    
 `. `'`     4096R/CAF14EFC 
   `-       081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20091202/8f2bf447/attachment.sig>


More information about the Python-list mailing list