Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37850

Re: what is the difference between commenting and uncommenting the __init__ method in this class?

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 <davea@davea.name>
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 <davea@davea.name>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1162.1359426026.2939.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

what is the difference between commenting and uncommenting the __init__ method  in this class? iMath <redstone-cold@163.com> - 2013-01-28 18:09 -0800
  Re: what is the difference between commenting and uncommenting the __init__ method  in this class? Dave Angel <davea@davea.name> - 2013-01-28 21:19 -0500
  Re: what is the difference between commenting and uncommenting the __init__ method  in this class? Mitya Sirenef <msirenef@lightbird.net> - 2013-01-28 22:00 -0500

csiph-web