On Mon, 01 Feb 2010 02:19:39 -0800, Joan Miller wrote: > Which is the best way to create user-defined exceptions since that > *BaseException.message* is deprecated in Python 2.6 ?
Inherit from an existing exception. >>> class MyValueException(ValueError): ... pass ... >>> >>> raise MyValueException("value is impossible, try again") Traceback (most recent call last): File "<stdin>", line 1, in <module> __main__.MyValueException: value is impossible, try again >>> class GenericError(Exception): ... pass ... >>> raise GenericError("oops") Traceback (most recent call last): File "<stdin>", line 1, in <module> __main__.GenericError: oops Do you need anything more complicated? -- Steven -- http://mail.python.org/mailman/listinfo/python-list