James Stroud wrote: > I was attempting to re-define iter of a subclassed list, to find the > "magic" method, but it didn't work.
>>> class List(list): ... def __iter__(self): return iter("abc") ... >>> a = List([1,2,3]) >>> list(a) ['a', 'b', 'c'] >>> tuple(a) (1, 2, 3) list-to-tuple conversion is optimized for performance -- basically a memcopy() of the internal data. As with a similar peculiarity with file.write() and the print statement, the problem could be shunned if python would check for the exact class instead of a test that is equivalent to isinstance(). Peter -- http://mail.python.org/mailman/listinfo/python-list