RE: list() coercion
At 10:42 AM 7/17/2003 +1000, Delaney, Timothy C (Timothy) wrote:
> > From: Ian Bicking [mailto:firstname.lastname@example.org]
> > 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?
303 442 2625
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
Re: list() coercion
> 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?
The Py2.3 release candidate goes out tonight.
In it, I've included sections on iterators and generators
in the tutorial. I'm interested to know whether you
find it helpful:
|All times are GMT. The time now is 11:00 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.