looking for design pattern name

Andrew Dalke adalke at mindspring.com
Thu Jul 31 23:23:03 CEST 2003


John J. Lee:
> Yuck.  Doesn't the standard library reserve TypeError for occasions
> where the, um, type of an argument is not appropriate?

Quoting from the docs,
   exception TypeError
   Raised when a built-in operation or function is applied to an object of
   inappropriate type. The associated value is a string giving details about
   the type mismatch.

In addition to your comments, this is not a built-in operation, so it's
the wrong exception.

> Why not ValueError or
> your own exception (possibly derived from ValueError)?

  exception ValueError
  Raised when a built-in operation or function receives an argument that
  has the right type but an inappropriate value, and the situation is not
  described by a more precise exception such as IndexError.

Yup, seems reasonable.  I'll change.  Thanks!

See you at the next Calvinball tournament, Spaceman Lee.

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list