jstroud at mbi.ucla.edu
Tue Nov 8 06:03:24 CET 2005
On Monday 07 November 2005 20:36, Alex Martelli wrote:
> > > I've looked at getitem, getslice, and iter. What is it if not one of
> > > these?
> Obviously James hadn't looked at __iter__ in the RIGHT way!
I was attempting to re-define iter of a subclassed list, to find the "magic"
method, but it didn't work. I'm not sure if "wrong" and "right" apply here:
py> class NewList(list):
... def __iter__(self):
... return iter([8,9,10])
py> n = NewList([1,2,3])
py> def doit(*args):
... print args
(1, 2, 3)
py> for x in iter(n):
... print x
UCLA-DOE Institute for Genomics and Proteomics
Los Angeles, CA 90095
More information about the Python-list