Type Hinting vs Type Checking and Preconditions

Diez B. Roggisch deets at nospam.web.de
Wed Mar 8 17:48:48 CET 2006


Tom Bradford wrote:

> This type of hinting would only break type ducking in-so-much as a
> function that leveraged that hinting would be looking specifically for
> an instance of a particular type, which would be absolutely no
> different than a developer performing the type check manually and
> throwing it out if the type were invalid.  It would otherwise just be a
> lot of tedious and repetitive work for the developer.

The thing with duck-typing is that exactly this kind of type-checking is
_not_ what the developer is supposed to do. Doing so breaks duck-typing
anyway, regardless of syntactic sugaring or not.

Adding such a feature would immediately start people creating code that for
example requires a list where an iterable would suffice - and thus eating
from the usability of python in general.

Diez



More information about the Python-list mailing list