Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37851
| Date | 2013-01-28 22:00 -0500 |
|---|---|
| From | Mitya Sirenef <msirenef@lightbird.net> |
| 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.1163.1359428411.2939.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll 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