Are there any PEPs for typed arguments?

Peter Hansen peter at
Mon Dec 3 06:14:02 CET 2001

Eugene wrote:
> What checks would you do to determine if a variable could be converted to an
> int without changing its value?
> And what checks would you do to safely determine if an object implements all
> the methods you want it to?  If it does implement all those methods, what
> assurance do you have of what the methods' return-types will be?
> Supporting compatible types is a good thing, but so is determining at the
> _start_ of a function that something is going to break because a contract
> (or an assumption) was not upheld.

No, that's what exceptions are for.  You assume things will work,
you try it, and you clean up when it fails.  Since it works more
often than it fails, this sounds faster, not to mention simpler,
and more maintainable.  And it's Python.

Peter Hansen, P.Eng.
peter at

More information about the Python-list mailing list