Xavier Ho wrote:
Why doesn't the second output print [1, 2, 3, .... , 7, 8, 9] ?
The code is run at: http://codepad.org/wgLU4JZh
class A():
def __init__(self):
self.n = [1, 2, 3, 4, 5]
a = A()
print a.n
print a.n.extend([6, 7, 8, 9])
#Output:
#[1, 2, 3, 4, 5]
#None
I really don't know, but I'm probably missing something. Any pointers
would be great.
The extend() method modifies the list in-place and returns None. Try
printing a.n after extending.
--
http://mail.python.org/mailman/listinfo/python-list