Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37851
| 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 | <msirenef@lightbird.net> |
| 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 <msirenef@lightbird.net> |
| 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 <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.1163.1359428411.2939.python-list@python.org> (permalink) |
| 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 |
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) > 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