[Tutor] Calling super in __init__
wcyee
wcyeee at gmail.com
Tue May 20 07:17:28 CEST 2008
Kent and Paul, Thanks very much for your help!
On Mon, May 19, 2008 at 8:43 AM, Paul McGuire <ptmcg at austin.rr.com> wrote:
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> Hi - I wrote a custom exception class as follows:
>
> class CustomError(Exception):
> def __init__(self, msg):
> super(CustomError, self).__init__(self, msg)
>
> But this doesn't work as expected:
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
> Correct use of super would be:
>
> class CustomError(Exception):
> def __init__(self, msg):
> super(CustomError, self).__init__(msg)
>
> (Don't add self as an argument.)
>
> Exception became a new-style class in Python 2.5.
>
> -- Paul
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080520/21103d95/attachment.htm>
More information about the Tutor
mailing list