On Sun, Jun 22, 2014 at 6:56 PM, Dylan Baker <[email protected]> wrote: > On Saturday, June 21, 2014 09:53:11 AM Ilia Mirkin wrote: >> On Sat, Jun 21, 2014 at 8:06 AM, Dylan Baker <[email protected]> > wrote: >> > Use super() instead of an explicit call to the parent class in one case, >> > and make all classes descend from object (make them new-style classes) >> > >> > Signed-off-by: Dylan Baker <[email protected]> >> > --- >> > >> > framework/results.py | 6 +++--- >> > 1 file changed, 3 insertions(+), 3 deletions(-) >> > >> > diff --git a/framework/results.py b/framework/results.py >> > index 7762d39..356aefb 100644 >> > --- a/framework/results.py >> > +++ b/framework/results.py >> > >> > @@ -53,7 +53,7 @@ def _piglit_encoder(obj): >> > return obj >> > >> > -class JSONWriter: >> > >> > +class JSONWriter(object): >> > ''' >> > Writes to a JSON file stream >> > >> > @@ -181,7 +181,7 @@ class JSONWriter: >> > class TestResult(dict): >> > def __init__(self, *args): >> > - dict.__init__(self, *args) >> > + super(TestResult, self).__init__(*args) >> >> I'm weak on the details, but I have an odd recollection of Guido >> telling me not to do that unless I was doing funny things with >> multiple inheritance. This was back when python 2.4 was cool. But if >> you know what you're doing, this is fine too. (Might also have had >> something to do with old- and new-style classes... it was a long time >> ago.) >> >> Acked-by: Ilia Mirkin <[email protected]> > > The argument constantly used on SO for super() (in python2, it's very concise > in python3 since it doesn't require arguments) is that if you change the > parent class you don't have to update calls. super() also works on the MRO, so > it can be a bit finiky with multiple inheritance, but I'm not a big fan of > multiple inheritance anyway (I have a background in Ruby and really like their > mixin/monkey patch apparch). super() also doesn't work on old style classes at > all (MRO is an attribute of new-style classes I think) > > I can drop that change if you prefer.
I don't feel too strongly one way or the other (hence the ack). But personally I avoid things I don't understand fully, and all that super() stuff is in a part of Python I've managed to avoid understanding :) Not to mention metaclasses. [I'm sure you can just see the love I have for Django emanating from these comments...] > >> >> > # Replace the result with a status object >> > >> > try: >> > @@ -192,7 +192,7 @@ class TestResult(dict): >> > pass >> > >> > -class TestrunResult: >> > >> > +class TestrunResult(object): >> > def __init__(self, resultfile=None): >> > self.serialized_keys = ['options', >> > >> > 'name', >> > >> > -- >> > 2.0.0 >> > >> > _______________________________________________ >> > Piglit mailing list >> > [email protected] >> > http://lists.freedesktop.org/mailman/listinfo/piglit _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
