Why does extend() fail in this case, and what am I doing wrong?

Xavier Ho contact at xavierho.com
Tue Jul 14 10:52:55 EDT 2009


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.

Best regards,

Ching-Yun "Xavier" Ho, Technical Artist

Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: contact at xavierho.com
Website: http://xavierho.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090714/716ef38c/attachment.html>


More information about the Python-list mailing list