Error checking in Python
Greg Ewing (using news.cis.dfn.de)
g2h5dqi002 at sneakemail.com
Tue Jun 10 23:13:41 EDT 2003
DavidW Blaschke wrote:
> It's o.k. to change the type to
> int because you are going to be checking the bounds
> anyway - assert 0 < month < 13.
Even then, you're cutting off the possibility of
someone passing you a type that can be compared
with ints and otherwise used as an int but not
convertible to an int. (Probably unlikely in the
case of ints, but there's a general principle
there somewhere.)
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list