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?

Date 2013-01-28 21:19 -0500
From Dave Angel <davea@davea.name>
Subject Re: what is the difference between commenting and uncommenting the __init__ method in this class?
References <0a5c1e54-4113-4f88-b249-8a4e3e05d303@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.1162.1359426026.2939.python-list@python.org> (permalink)

Show all headers | 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