O'Reilly logo
  • Sri Harsha V thinks this is interesting:

files also have a method named __next__ in 3.X (and next in 2.X) that has a nearly identical effect—it returns the next line from a file each time it is called. The only noticeable difference is that __next__ raises a built-in StopIteration exception at end-of-file instead of returning an empty string:



Cover of Learning Python, 5th Edition


So, in effect this next(in python 2.x) and next method is what makes a python object iterable.