[Python-3000] Builtin iterator type

Andrew Koenig ark-mlist at att.net
Sun Nov 19 18:03:28 CET 2006


> It strikes me that one aspect of "being Pythonic" is a strong reliance
> on politeness: that's what duck-typing is all about.

Part of my motivation for entering this discussion is that C++ templates use
duck-typing, and the C++ community has for several years been thinking about
how to add more explicit constraints to the type system.

One motivation is easier diagnostics: If by mistake you hand a non-sequence
to something that requires a sequence, it would be nice for the compiler to
be able to say "This argument does not satisfy the 'sequence' constraint"
rather than spewing forth a page of error messages generated deep in the
internals of the library.

I understand that this exact motivation doesn't apply in Python because of
its dynamic typing.  However, I've seen examples in Python that feel to me
like that address similar problems to the ones in C++.  Of course, such
feelings don't prove anything; but sometimes they help point the way to a
useful solution.




More information about the Python-3000 mailing list