En Wed, 07 Mar 2007 10:29:29 -0300, Alan Franzoni <[EMAIL PROTECTED]> escribió:
> Il Tue, 06 Mar 2007 01:55:54 -0300, Gabriel Genellina ha scritto: > If we rely on duck typing, by the way, we may encounter two types > quacking > like ducks, flying like ducks, but in fact acting as slightly different > ducks. I should remember as well, when designing a container type that I > want to use in place of a list, to carefully craft an __iadd__ method > which > works just like the a list's own __iadd__ method; if I forget, I may > introduce a subtle error. I'm not sure of your concerns. If you want to provide your own container that mimics a list, there are a lot more things to consider than __iadd__ (See the UserList class or this ListMixin recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440656). __iadd__, in general, is not *required* to modify the instance in place (but should try to do that, if possible). After this code: b = a a += c you can't assert than a and b both refer to the *same* object, as before. If you need that, don't use += at all. (For a generic object, I mean. The built-in list "does the right thing", of course) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list