Author eric.snow
Recipients KayEss, Rhamphoryncus, benjamin.peterson, blakeross, eric.snow, georg.brandl, gregory.p.smith, gvanrossum, jaraco, jcea, jonash, rhettinger, terry.reedy
Date 2014-05-28.15:39:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CALFfu7CQJN45Xk8e4i9XB6ncU197u3Quskx=0hLLAU1vJjakVw@mail.gmail.com>
In-reply-to <1401289509.54.0.542244672138.issue1683368@psf.upfronthosting.co.za>
Content
> If you don't know enough about the base class you shouldn't be subclassing it.

That's important when overriding any API in subclass and absolutely
always essential when it comes to __new__ and __init__!  That's
something that isn't very obvious at first. :(

> In this particular case you should be overriding __init__, not __new__.

Jason's code is doing something like OSError.__new__ does now, which
returns an instance of a subclass depending on the errno.  However,
while the language supports it, I see that as a viable hack only when
backward-compatibilty is a big concern.  Otherwise I find factory
classmethods to be a much better solution for discoverability and
clarity of implementation.
History
Date User Action Args
2014-05-28 15:39:11eric.snowsetrecipients: + eric.snow, gvanrossum, georg.brandl, rhettinger, terry.reedy, gregory.p.smith, jcea, jaraco, Rhamphoryncus, blakeross, benjamin.peterson, KayEss, jonash
2014-05-28 15:39:11eric.snowlinkissue1683368 messages
2014-05-28 15:39:10eric.snowcreate