Haskell like (c:cs) syntax

Marco Mariani marco at sferacarta.com
Wed Aug 29 12:08:23 CEST 2007

Ricardo Aráoz ha scritto:

> L = ['one', 'two', 'three', 'four', 'five']
> print L[0]    # This would be 'head'
> print L[1:]   # This would be 'tail'
> Caution : L[0] and L[1:] are COPIES of the head and tail of the list.

This might surprise people who see L[1:] = [], since changing a copy is 
not supposed to change the original.

More information about the Python-list mailing list