A strange behavior of list.extend()

Lee Harr missive at frontiernet.net
Sun Aug 24 18:54:47 EDT 2003


In article <420ced91.0308241311.734cbc9c at posting.google.com>, sdhyok wrote:
> I think the two script should produce the same results, but not.
> Why?
> 
> ---------------- Script #1
> ls = [1]
> ls.extend([2,3])
> print ls
> -> [1,2,3]
> 
> --------------- Script #2
> ls = [1].extend([2,3])
> print ls
> -> None
> 

a_list.extend returns None, not a_list.

It is the same as the way a_list.sort works.





More information about the Python-list mailing list