Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   RE: list() coercion (http://www.velocityreviews.com/forums/t319815-re-list-coercion.html)

Bob Gailer 07-17-2003 01:41 PM

RE: list() coercion
 
At 10:42 AM 7/17/2003 +1000, Delaney, Timothy C (Timothy) wrote:

> > From: Ian Bicking [mailto:ianb@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@alum.rpi.edu
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


Raymond Hettinger 07-17-2003 07:29 PM

Re: list() coercion
 
[Bob Gailer]
> 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:

http://www.python.org/dev/doc/devel/...00000000000000
0


Raymond Hettinger




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.