March 2003
Intermediate to advanced
656 pages
39h 30m
English
__iter__
__iter__(self)
For a request to loop on all items of x
(typically for
item
in
x), Python calls
x
.__iter__( ) to
obtain an iterator on x. The built-in
function
iter(
x
)
also calls x
.__iter__( ). If __iter__ is absent and
x is a sequence,
iter(
x
)
synthesizes and returns an iterator object that wraps
x and returns
x
[0],
x
[1], and so on, until
one of these item accesses raises IndexError to
indicate the end of the sequence.