Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'explicitly': 0.05; '"""': 0.07; 'class,': 0.07; 'versions.': 0.07; '__init__': 0.09; 'default.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'jan': 0.12; '__new__': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'old-style': 0.16; 'redundant': 0.16; 'subclass': 0.16; 'subclassing': 0.16; 'subject:class': 0.16; 'subject:python2.7': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'appears': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'important.': 0.30; 'message-id:@mail.gmail.com': 0.30; 'class': 0.32; 'there.': 0.32; 'probably': 0.32; 'skip:_ 10': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'two': 0.37; 'though,': 0.39; 'simply': 0.61; "you're": 0.61; 'different': 0.65; 'object:': 0.84; 'subtly': 0.84; 'thing,': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=pZyeDHvFALzs9JGleGY5icLpLsRlQw7Y5qtWzYnPoSs=; b=XzyynRmiAxXVL4RuDeH7Rcn547b5lsV3aFZPxIV0D4v6l9QYlQZs+BEsiMwjx+qd2s dmbb6t2NPOfJIbV4YHuqU+4YHRPmmRkVPlqeuuiYjqS58i2li3QA/4NAMuyc8r1jAhN6 f6T+yVj1K4W5S6nQ6UsXvY3amtkDVugeTBJgRquLAMyWP4axWY6mvsI1BMvDsCh9JqAW 1HT8AYmbU0K/j1C5zW6jWHkJ0Dl46vzwg37mYINKSGMCDGlpOyIMurG7VrKTbFEIJDJG oTrHEA3PepZR0ryj/3SDwC4qRnZZUdIpheFwengWiiTXtV271ekd3cuNLAWnMdf+zo+G QWLA== MIME-Version: 1.0 X-Received: by 10.68.183.164 with SMTP id en4mr7660983pbc.169.1389029081245; Mon, 06 Jan 2014 09:24:41 -0800 (PST) In-Reply-To: References: Date: Tue, 7 Jan 2014 04:24:41 +1100 Subject: Re: class inheritance python2.7 vs python3.3 From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389029091 news.xs4all.nl 2871 [2001:888:2000:d::a6]:47591 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63310 On Tue, Jan 7, 2014 at 4:14 AM, 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