On Thu, 2006-03-23 at 14:52 -0500, Jim Fulton wrote:

> If we are dead set on making these methods return iterators, I'd really like
> to see a way to either get non-iterators by calling a method or see some
> new facilities in the iterators returned.  Perhaps these iterators
> could have a method for getting a set of values?

What I've found painful as we converted all of our api's from returning
lists (or tuples) to returning iterators, is that the few places that
did random access into the concrete sequence broke, requiring a wrapping
of list() of some other fix.

What I think would be useful would be to add /optional/ support for
__getitem__() to certain iterators.  IOW, iterators could chose to
support random access or not.  So, dict().keys could support
__getitem__() because it knows the size of the iterator's underlying
sequence.  Generators and other iterators could chose to raise TypeError
if they have an unknown size.

There are probably all sorts of reasons why this won't work, but it
seems like it would be useful.

-Barry

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to