class inheritance python2.7 vs python3.3
Chris Angelico
rosuav at gmail.com
Mon Jan 6 12:24:41 EST 2014
On Tue, Jan 7, 2014 at 4:14 AM, <jwe.van.dijk at gmail.com> wrote:
> class LPU3(LPU1):
> def __new__(self):
> """
> the same functions as LPU1 but some added functions
> and some functions redefined
> """
You probably don't want to be using __new__ here. Try using __init__
instead, or simply not defining __new__ at all.
I suspect that the reason that appears to work under Py2 is that
you're using an old-style class, there. That means it'll be subtly
different on the two versions. To make them do the same thing,
explicitly subclass object:
class LPU1(object):
In Python 3, that's redundant - subclassing object is the default. In
Python 2, though, it's important.
ChrisA
More information about the Python-list
mailing list