list() coercion
Bob Gailer
bgailer at alum.rpi.edu
Thu Jul 17 09:41:06 EDT 2003
At 10:42 AM 7/17/2003 +1000, Delaney, Timothy C (Timothy) wrote:
> > From: Ian Bicking [mailto:ianb at colorstudy.com]
> >
> > Is there a way I can keep this from happening? Maybe something list()
> > tries first that I can make fail. (I notice list() catches any
> > exceptions in __len__ and then will just skip that step)
>
>Simplest thing is probably:
>
>ll = MyListLikeObject()
>li = iter(ll)
>l = list(li)
>
>i.e. explicitly create an iterator (which doesn't have a __len__) and
>create the list from that.
>
>OTOH, if the problem is that creating the iterator is causing the problem
>(calling __len__), you may need to create a proxy object that doesn't have
>a __len__ and call list() on that.
I have just read the docs 2.2.5 Iterator Types. Unfortunately this page
seems to be written for someone who already understands the page. Is there
any other explanation or examples?
Bob Gailer
bgailer at alum.rpi.edu
303 442 2625
-------------- next part --------------
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.500 / Virus Database: 298 - Release Date: 7/10/2003
More information about the Python-list
mailing list