On Dec 9, 2007 3:21 PM, hashcollision <[EMAIL PROTECTED]> wrote: > From http://ivory.idyll.org/blog/dec-07/conversions.html: > > class X: > internal = [5,6,7,8] > def __getitem__(self, i): > return self.internal[i] > > x = X() > > l = [1,2,3] > print l + x > > fails with > > TypeError: can only concatenate list (not "instance") to list > > If you want class X to understand "+" via duck-typing, overload __add__ and __radd__.
-- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises LLC
_______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com