list() coercion

Greg Ewing (using news.cis.dfn.de) g2h5dqi002 at sneakemail.com
Fri Jul 18 02:25:32 EDT 2003


Ian Bicking wrote:
> I'm not clear on how that will help...?  
> 
> It already does have an __iter__ method, but it returns a separate
> iterator.

It turns out that it won't help. I had thought that
calling __len__ would only happen if there were no
__iter__ method, but that seems not to be the case.

The only thing I can think of at the moment is not
to do list(x) at all, but list(iter(x)) instead.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list