Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'lines.': 0.07; 'override': 0.07; '*args):': 0.09; '__init__': 0.09; 'python:': 0.09; 'subject:method': 0.09; 'def': 0.10; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; '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; "doesn't": 0.28; 'subject:what': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; 'normally': 0.30; 'code': 0.31; 'to:addr:python-list': 0.33; 'pm,': 0.35; 'subject:?': 0.35; 'something': 0.35; 'there': 0.35; 'add': 0.36; 'but': 0.36; 'method': 0.36; 'anything': 0.36; 'well.': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'delete': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'between': 0.63; 'therefore': 0.65; 'to,': 0.65; 'subject: ': 0.66; 'subject:this': 0.84; 'clearer': 0.84; 'commenting': 0.91 Date: Mon, 28 Jan 2013 22:00:00 -0500 From: Mitya Sirenef 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-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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1359428411 news.xs4all.nl 6959 [2001:888:2000:d::a6]:38153 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37851 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) > No difference as this code doesn't do anything else in the __init__() it overrides. Normally you would add some additional processing there but if you don't need to, there is no reason to override __init__(), therefore it's clearer and better to delete those 2 lines. -m -- Lark's Tongue Guide to Python: http://lightbird.net/larks/ It is always pleasant to be urged to do something on the ground that one can do it well. George Santayana