class inheritance python2.7 vs python3.3

jwe.van.dijk at gmail.com jwe.van.dijk at gmail.com
Mon Jan 6 12:14:08 EST 2014


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



More information about the Python-list mailing list