list behavior

Batista, Facundo FBatista at uniFON.com.ar
Mon Oct 27 13:33:27 EST 2003


#- Not what I expected, then I came to the conclusion that
#- [].append(value) returns 'None', why?

Because it's the defined behaviour, ;)


>>> help([].append)
Help on built-in function append:

append(...)
    L.append(object) -- append object to end


It just modifies the object, return None:

>>> l = [3]
>>> a = l.append(5)
>>> l
[3, 5]
>>> a
>>> repr(a)
'None'

.	Facundo





More information about the Python-list mailing list