Armin wrote: > Duncan Booth wrote: >> "Chris Rebert" <[EMAIL PROTECTED]> wrote: >>> On Tue, Sep 16, 2008 at 1:20 AM, Armin <[EMAIL PROTECTED]> wrote: >>>> [1,2,3,4,7].append(c) -> Is this a valid expression? >>> Literally, no, because you can't call methods on literals. >> >> Rubbish. There is no restriction about calling methods on literals. >> That expression is perfectly valid but has no practical use that I can >> see. > > The semantic of [1,2,3,4,7].append(c) and [1,2,3,4,7] + c > (with c = [8,9]) is identical, but the first expression doesn't provide > a value. Strange by design ... > Have a care, there. The semantics are different.
lst = [1, 2, 3, 4, 7] lst.append([8, 9]) makes lst [1, 2, 3, 4, 7, [8, 9]] whereas lst = [1, 2, 3, 4, 7] lst = lst + [8, 9] makes lst [1, 2, 3, 4, 5, 7, 8, 9] I suspect you meant [1, 2, 3, 4, 5, 7] + [c] regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list