Why list.sort() don't return the list reference instead of None?

Erik Max Francis max at alcyone.com
Mon May 8 08:42:55 CEST 2006

ankyhe at gmail.com wrote:

> L = [4,3,2,1]
> L=L.sort()
> L will refer to None, why L.sort() don't return the L?
> I want to ask why the designer of Python do so?

Because that's the convention that signifies that a Python method 
mutates the object rather than returns a new one.

Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Sitting in the den and / Looking at the phone as if it owed / Owed me
   a favor -- Blu Cantrell

More information about the Python-list mailing list