On Tue, 09 Oct 2007 19:46:35 +0000, Marc 'BlackJack' Rintsch wrote: > On Tue, 09 Oct 2007 18:08:34 +0000, Steven D'Aprano wrote: > >>>>> L = [] >>>>> id(L) >> 3083496716L >>>>> L += [1] >>>>> id(L) >> 3083496716L >> >> It's the same L, not rebound at all. > > It *is* rebound. To the same object, but it *is* assigned to `L` and > not just mutated in place.
Picky picky. Yes, technically there is an assignment of L to itself. I was sloppy to say "not rebound at all", because when you write an augmented assignment method you have to return self if you want to implement in-place mutation. But I hardly call "rebinding to itself" any sort of rebinding worth the name :) Diez is still wrong though, even though I overstated my case. See my reply to his post. [snip code] > If it was just mutation then `B.a` would have triggered an > `AttributeError`. Why? Don't Python classes have inheritance? (That's a rhetorical question. Yes they do, and no B.a would not raise AttributeError because it would inherit from A.) -- Steven. -- http://mail.python.org/mailman/listinfo/python-list