Return an iterator object. The first argument is interpreted very differently depending on the presence of the second argument. Without a second argument, o must be a collection object which supports the iteration protocol (the __iter__() method), or it must support the sequence protocol (the __getitem__() method with integer arguments starting at 0). If it does not support either of those protocols, TypeError is raised. If the second argument, sentinel, is given, then o must be a callable object. The iterator created in this case will call o with no arguments for each call to its next() method; if the value returned is equal to sentinel, StopIteration will be raised, otherwise the value will be returned.
也就是说
i = iter(x)
之后,因为x有__getitem__, i就是iterable的了
[ 本帖最后由 pastebt 于 2009-5-30 04:43 编辑 ]作者: ymr 时间: 2009-05-30 05:06
提示: 作者被禁止或删除 内容自动屏蔽作者: izhier 时间: 2009-05-30 09:08
四楼中:
or it must support the sequence protocol
(the __getitem__() method with integer arguments starting at 0).