Type Hinting vs Type Checking and Preconditions

Tom Bradford bradford653 at gmail.com
Wed Mar 8 11:28:23 EST 2006


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 fact is, as valuable as type ducking is, it has drawbacks in its
ambiguousness, that are especially harmful to large systems that are
being developed with many hands in the pot.  And no, people who use a
library that leverages this type of hinting are most certainly no more
effected by it than they would be by the methods performing the check
manually.

As the feature is optional, if you want to allow a method that allows
for type ducking, you would write it in exactly the same way you write
it now, and nobody would be harmed in the process.




More information about the Python-list mailing list