On Monday, 6 January 2014 18:14:08 UTC+1, jwe.va...@gmail.com wrote: > I have problems with these two classes: > > > > class LPU1(): > > def __init__(self, formula): > > """ > > formula is a string that is parsed into a SymPy function > > and several derived functions > > """ > > self.formula = formula > > ... ... > > > > class LPU3(LPU1): > > def __new__(self): > > """ > > the same functions as LPU1 but some added functions > > and some functions redefined > > """ > > ... ... > > > > if __name__ == '__main__: > > y = y = 'x_0 * x_1 + x_2' > > stats1 = LPU1(y) > > stats3 = LPU3(y) > > > > Worked perfectly on Python 2.7.5+ but on Python 3.3.2+ I get on > instantiatiating stat3: > > TypeError: __new__() takes 1 positional argument but 2 were given > > > > What am I doing wrong? > > I must confess I am a bit out of my depth here so any explanation will be a > learning experience. > > > > Many thanks, Janwillem
Thanks for all the contributions. I now have: class LPU1(object): def __init__(self, formula): ... ... and class LPU3(LPU1): def __init__(self, y): LPU1.__init__(self, y) ... ... which gives the correct results both on 2.7 and 3.3. Is that more or less good practice? Now I stumble on a SymPy problem under 3.3 but that obviously is an other topic Cheers, janwillem -- https://mail.python.org/mailman/listinfo/python-list