On Sun, 11 Jul 2010 08:59:06 -0700 (PDT) dhruvbird <dhruvb...@gmail.com> wrote: > Why doesn't python's list append() method return the list itself? For > that matter, even the reverse() and sort() methods? > I found this link (http://code.google.com/edu/languages/google-python- > class/lists.html) which suggests that this is done to make sure that > the programmer understands that the list is being modified in place, > but that rules out constructs like: > ([1,2,3,4].reverse()+[[]]).reverse() > I want to prepend an empty list to [1,2,3,4]. This is just a toy > example, since I can always do that with [[]]+[1,2,3,4].
>>> x = [1,2,3,4] >>> y = [5,6] >>> x[:0] = y >>> x [5, 6, 1, 2, 3, 4] -- http://mail.python.org/mailman/listinfo/python-list