Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'classes.': 0.05; 'retained': 0.07; 'python': 0.08; 'default.': 0.09; 'received :mail-lpp01m010-f46.google.com': 0.09; 'am,': 0.12; 'classes,': 0.13; 'class,': 0.15; 'mro': 0.16; 'new-style': 0.16; 'cc:addr :python-list': 0.16; 'wrote:': 0.18; 'cheers,': 0.20; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'indirectly': 0.23; 'cc:2**0': 0.26; 'classes': 0.26; 'function': 0.27; 'pass': 0.29; 'message-id:@mail.gmail.com': 0.29; 'class': 0.29; 'cc:addr:python.org': 0.29; 'object.': 0.30; 'sun,': 0.30; 'received:209.85.215.46': 0.32; 'there': 0.33; 'two': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'introduced': 0.39; 'received:209.85.215': 0.39; 'received:209': 0.39; "you'll": 0.61; 'your': 0.61; '11,': 0.68; '2.2.': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=icqcOVRBWoGIvz/0mHZcbiut1jcIOJr3iRAZhRLwM6k=; b=QEqyu23Em4rMG+vjUJhq86FN+2VQgZzl7jZRXRNAesy/gPA/2i7+1NmRys0nIp9/AU +VkdVpeXP9H0it4zMGh/qEo2XzE8MQVkVYI8w/uKq0zL0bXUuhupxCd77/8voyLQNLMp GAHxiPg99ldD9iw6CEQyq+X35O3Fihjz70/PuF81afmn+D4VdSv8EmMaIGNWtbHat9iR BFFgZHoEVvOoyjRLoto72LxZh8vGp5ss73K+OxVM4W0JqNTfUg0/KsgjsoxeQeYDEWvb VKlzgMZUcNNuPjW5FZyxVBjhEk6LOkzGjkj9P2S+o4SWTAEWxZXpgeLWwY19057BSJrp P/Qg== MIME-Version: 1.0 In-Reply-To: <18769501.3541.1331463388634.JavaMail.geo-discussion-forums@ynkz21> References: <1c6db866-6fa3-4de5-96de-51d6720a1300@x17g2000yqj.googlegroups.com> <2feb13ca-f83b-4843-995f-ee77e7505ecd@db5g2000vbb.googlegroups.com> <18769501.3541.1331463388634.JavaMail.geo-discussion-forums@ynkz21> From: Ian Kelly Date: Sun, 11 Mar 2012 05:40:53 -0600 Subject: Re: newb __init__ inheritance To: hyperboogie Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1331466085 news.xs4all.nl 6926 [2001:888:2000:d::a6]:43158 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21491 On Sun, Mar 11, 2012 at 4:56 AM, hyperboogie wrote: > 1. What do you mean by "subclassing `object`"? In Python 2 there are two different types of classes: classic classes, which are retained for backward compatibility, and new-style classes, which were introduced in Python 2.2. Classic classes are the default. In order to get a new-style class (strongly recommended), your class must inherit directly or indirectly from object. In the following, A and B are classic classes, whereas C and D are new-style classes: class A: pass class B(A): pass class C(object): pass class D(C): pass In Python 3, classic classes have been removed, and so all four of the classes above would be new-style. > 2. Is the mro function available only on python3? No, but it is available only on new-style classes. If you try it on a classic class, you'll get an AttributeError. Cheers, Ian