On Thursday 26 May 2011 14:46:45 Uncle Ben wrote:
> In playing with lists of lists, I found the following:
> 
> (In 3.1, but the same happens also in 2.7)
> 
> list = [1,2,3]
> list.append ( [4,5,6] )
> x = list
> x   ->
>     [1,2,3,[4,5,6]]
> as expected.
> 
> But the shortcut fails:
> 
> list=[1,2,3]
> x = list.append( [4,5,6] )
> x   ->
>    nothing
> 
> Can someone explain this to me?
> 
> Uncle Ben

And why do you insist on calling and instance of list, "list"? 
Even a human reader will confuse which is which.  What you are 
showing is an example how confusing things become when a keyword 
(list) is over-written (with  list instance).

Why don't you just say

lst = [1, 2, 3]

rather than list =...   It may be permissible, but it is not a 
good idea!

Old (practical) Al.
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to