for each in: Pythonic?

Started by
9 comments, last by swiftcoder 8 years, 8 months ago


Certainly not. python can work on different types just like some kind of type erasure system. they are not polymorphic but some operations can apply to a whole variety of types

See my post and Oluseyi's, right before your own.

Duck typing (to which you are referring) is equivalent to polymorphism, at least in this context. That means that anything you do with duck typing, you could just as well accomplish through polymorphism by declaring a set of common interfaces, albeit requiring more verbosity - duck typing effectively just allows one to elide the interface declarations, and instead resolve types at runtime.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement