On 10/15/2012 12:34 PM, MRAB wrote: > On 2012-10-15 17:22, John Gordon wrote: >> In <mailman.2217.1350317845.27098.python-l...@python.org> MRAB >> <pyt...@mrabarnett.plus.com> writes: >> >>> > Why wasn't the message printed out? >>> >>> You didn't add a __str__ method: >> >>> class PvCamError(Exception): >>> def __init__(self, msg): >>> self.msg = msg >>> def __str__(self): >>> return self.msg >> >> Wouldn't PvCamError inherit __str__() from Exception? >> > Yes, but you've put the message in msg, and Exception doesn't have that > attribute. > > An alternative approach would be: > > class PvCamError(Exception): > pass >
Wouldn't another approach be for this __init__() method to call the base-class __init__() method with whatever data it needs? -- DaveA -- http://mail.python.org/mailman/listinfo/python-list