Why doesn't this work?

Courageous jkraska at san.rr.com
Fri Dec 7 07:56:38 CET 2001

On Thu, 6 Dec 2001 23:23:42 -0500, "Tim Peters" <tim.one at home.com>


>You didn't say what you expected, so how should we know <wink>?

>x = [1, 2, 3]
>y = x.append(4)
>instead.  "How come got 4 stuffed at the end of x too?"

I suppose you're right. I just hadn't been coding Python very
much recently and forgot about append returning None. In other
environments, I've noticed a tendency for mutators to return
what was mutated.

I've been recently coding in Lisp; append and remove are
list operations there with behavior which is different in
a less-than-desireable way.

I'm always making small errors like this, moving from one
language to the next. Jumping back and forth between C++ and
Java is usually the most mind-bending.


More information about the Python-list mailing list