On 2005-01-15, at 23.50, Just van Rossum wrote:
Phillip J. Eby wrote:
But it _does_ perform an implicit adaptation, via PyObject_GetIter.
First, that's not implicit. Second, it's not adaptation, either.
PyObject_GetIter invokes the '__iter__' method of its target -- a
method that is part of the *iterable* interface. It has to have
something that's *already* iterable; it can't "adapt" a non-iterable
into an iterable.
Further, if calling a method of an interface that you already have in
order to get another object that you don't is adaptation, then what
*isn't* adaptation? Is it adaptation when you call 'next()' on an
iterator? Are you then "adapting" the iterator to its next yielded
value?
That's one (contrived) way of looking at it. Another is that
y = iter(x)
adapts the iterable protocol to the iterator protocol.
Especially since an iterable can also be an object without an __iter__
method but with a __getitem__ method. Calling __iter__ might get an
iterator, but calling __getitem__ does not. That seems like adaptation.
No? It's still not clear to me, as this shows, exactly what counts as
what in this game.
//Simon
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com