On Sat, Apr 21, 2012 at 6:03 AM, Jan Sipke <jansi...@gmail.com> wrote:
> Can you explain why there is a difference between the following two
> statements?
>
>>>> a = []
>>>> a.append(1)
>>>> print a
> [1]

This looks at the list after appending.

>>>> print [].append(1)
> None

This looks at the return value of the append() method. Since it
doesn't return self, the return value isn't much use. Incidentally,
your function call in the first block would have displayed the return
value had it not been None - that's how the interactive interpreter
works.

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to