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

Pablo Torres N. tn.pablo at gmail.com
Tue Jul 14 11:07:29 EDT 2009


This has been asked extensively before, here and elsewhere.

On Tue, Jul 14, 2009 at 09:52, Xavier Ho<contact at xavierho.com> 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.
>
> 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/
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>



-- 
Pablo Torres N.



More information about the Python-list mailing list