Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63308

class inheritance python2.7 vs python3.3

Newsgroups comp.lang.python
Date 2014-01-06 09:14 -0800
Message-ID <c552f556-4753-42dc-a2ae-e9d974f33949@googlegroups.com> (permalink)
Subject class inheritance python2.7 vs python3.3
From jwe.van.dijk@gmail.com

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

class inheritance python2.7 vs python3.3 jwe.van.dijk@gmail.com - 2014-01-06 09:14 -0800
  Re: class inheritance python2.7 vs python3.3 Chris Angelico <rosuav@gmail.com> - 2014-01-07 04:24 +1100
  Re: class inheritance python2.7 vs python3.3 Dave Angel <davea@davea.name> - 2014-01-06 12:46 -0500
  Re: class inheritance python2.7 vs python3.3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-07 05:10 +1100
  Re: class inheritance python2.7 vs python3.3 jwe.van.dijk@gmail.com - 2014-01-06 12:57 -0800

csiph-web