Path: csiph.com!usenet.pasdenom.info!aioe.org!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; '__init__': 0.09; 'attributes': 0.09; 'falls': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'language.': 0.14; '(django,': 0.16; '.py': 0.16; '__new__': 0.16; 'edx,': 0.16; 'grep': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'sqlalchemy,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'topic': 0.29; 'work.': 0.31; 'code': 0.31; "skip:' 10": 0.31; 'existence': 0.31; 'searches': 0.31; 'programmers': 0.33; 'subject:the': 0.34; 'could': 0.34; "can't": 0.35; 'anywhere': 0.35; 'something': 0.35; 'doubt': 0.36; 'like,': 0.36; 'doing': 0.36; 'to:addr:python-list': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'remove': 0.60; 'advanced': 0.63; 'our': 0.64; 'taking': 0.65; 'believe': 0.68; 'smith': 0.68; 'ranges': 0.74; 'article': 0.77; '228': 0.84; 'batchelder': 0.84; 'territory': 0.84; 'ratio': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: __init__ is the initialiser Date: Sat, 01 Feb 2014 15:07:18 +0000 References: <52ec6d1f$0$29972$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-92-24-219-97.ppp.as43234.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391267257 news.xs4all.nl 2844 [2001:888:2000:d::a6]:57006 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65219 On 01/02/2014 14:40, Roy Smith wrote: > In article , > Ned Batchelder wrote: > >> The existence of __new__ is an >> advanced topic that many programmers never encounter. Taking a quick >> scan through some large projects (Django, edX, SQLAlchemy, mako), the >> ratio of __new__ implementations to __init__ implementations ranges from >> 0% to 1.5%, which falls into "rare" territory for me. > > From our own codebase: > > $ find . -name '*.py' | xargs grep 'def.*__new__' | wc -l > 1 > $ find . -name '*.py' | xargs grep 'def.*__init__' | wc -l > 228 > > Doing the same searches over all the .py files in our virtualenv, I get > 2830 (__init__) vs. 50 (__new__). > You could remove all 228 __init__ and still get your code to work by scattering object attributes anywhere you like, something I believe you can't do in C++/Java. I doubt that you could remove the single __new__ and get your code to work. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence