Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!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.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'method,': 0.07; '*args):': 0.09; '__init__': 0.09; 'empty,': 0.09; 'subject:method': 0.09; 'def': 0.10; 'subject: \n ': 0.16; 'subject:between': 0.16; 'subject:class': 0.16; 'wrote:': 0.17; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'subject:what': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; 'to:addr:python-list': 0.33; 'list': 0.35; 'pm,': 0.35; 'subject:?': 0.35; "won't": 0.35; 'method': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'between': 0.63; 'subject: ': 0.66; 'received:74.208': 0.71; 'subject:this': 0.84; 'commenting': 0.91 Date: Mon, 28 Jan 2013 21:19:50 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: python-list@python.org Subject: Re: what is the difference between commenting and uncommenting the __init__ method in this class? References: <0a5c1e54-4113-4f88-b249-8a4e3e05d303@googlegroups.com> In-Reply-To: <0a5c1e54-4113-4f88-b249-8a4e3e05d303@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:eEYDM2Dbj7oPh12vNsltPCv1utZN71mehcunkLMkY6q ZUVNtlnphX2yxHvA5ckGG1pE/v2G5BtLdK1ZnXgzBu/N0tek+K E4pPUrcmSol9U8uVjAy0bkstmM8SShbQtYGuesRXA8Je2bbG3o xYU58OBQUKAojwm0kCj7U8jZI7Doz1e2R16g11pHWlf/DYA88S mq9CwyD/mWTyC1hU/q6EFfvRIye8JiED0sLVSQm/zKYtY3xUJM X3rTAFE7Pp5mDDVU+h5CY6ZMXKZPlfzy+09sawTFq8sjVGUUTN dEj/V46y9GxMGo1EkjzIAKVexxIW0oJeSTh7oPtftLcRlWFBw= = 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: 1359426026 news.xs4all.nl 6922 [2001:888:2000:d::a6]:34472 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37850 On 01/28/2013 09:09 PM, iMath wrote: > what is the difference between commenting and uncommenting the __init__ method in this class? > > > class CounterList(list): > counter = 0 > > ## def __init__(self, *args): > ## super(CounterList, self).__init__(*args) > > def __getitem__(self, index): > > self.__class__.counter += 1 > return super(CounterList, self).__getitem__(index) > If you don't call the super-class' __init__() method, then the list won't take anyparameters. So the list will be empty, -- DaveA