Raymond Hettinger added the comment:

It's the nature of duck typing in a dynamic language.  You can tell whether 
something is present but can't tell whether it words correctly until you call 
it.

For example, in Python 3, all objects have __lt__ defined, but all it does is 
return NotImplemented.  So, you can't really tell whether something is 
orderable until you make the less-than call.

In your case, the rule is that if "next" is present, we assume that it is 
iterable, but it won't be until it is called that we can tell whether it is 
implemented correctly (i.e. is callable with zero arguments, returns a value, 
and raises StopIteration when done).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17584>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to