Defining a new exception with multiple args
Daniel Klein
danielk at aracnet.com
Sat Jan 13 11:20:16 EST 2001
On Thu, 11 Jan 2001 20:01:39 GMT, "Randall Kern" <randy at spoke.net> wrote:
>You could also override __str__:
>
>class RecordNotFoundException(Exception):
> def __init__(self, filename, recordid):
> self.filename = filename
> self.recordid = recordid
>
> def __str__(self):
> return '%s(%s)' % (self.filename, self.recordid)
Yes, this is a good solution.
Thanks,
Dan
More information about the Python-list
mailing list