a sequence question

Nick Coghlan ncoghlan at iinet.net.au
Fri Feb 11 22:34:15 EST 2005


David Isaac wrote:
> If that is right, I still cannot extract it from the doc cited above.
> So where should I have looked?

Ouch. The terminology's evolved, and it looks to me like the docs for the older 
builtins haven't been updated to track it.

The terminology has pretty much settled to 'iterable' for anything which returns 
a sensible result from iter(obj), 'iterator' for any iterable which returns 
itself from iter(obj), 'reiterable' for any iterable which is not an iterator, 
and 'sequence' for any reiterable which supports len(obj) and integer indexing.

That's not the terminology the older docs use, though, even in the most recent 
versions of that page [1].

For most of them it's OK, since the text clarifies what the term means in 
context (e.g. that 'sequence' actually means 'iterable' for some function 
signatures). zip() doesn't do that though - it actually accepts iterables, but 
only talks about sequences.

A bug report on Sourceforge would help in getting the problem fixed for the 2.5 
docs (possibly even the 2.4.1 docs if it happens soon). 2.3's a lost cause 
though, since 2.3.5 is already out the door and only another security bug is 
likely to trigger a new 2.3 release.

For the 'left-to-right' evaluation thing, that's technically an implementation 
artifact of the CPython implementation, since the zip() docs don't make any 
promises. So updating the docs to include that information would probably be a 
bigger issue, as it involves behaviour which is currently not defined by the 
library.

Cheers,
Nick.

[1] http://www.python.org/dev/doc/devel/lib/built-in-funcs.html
-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list