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


Groups > comp.lang.python > #65219

Re: __init__ is the initialiser

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 <python-python-list@m.gmane.org>
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 <breamoreboy@yahoo.co.uk>
Subject Re: __init__ is the initialiser
Date Sat, 01 Feb 2014 15:07:18 +0000
References <lcgtpf$tui$1@ger.gmane.org> <mailman.6217.1391197950.18130.python-list@python.org> <52ec6d1f$0$29972$c3e8da3$5496439d@news.astraweb.com> <mailman.6275.1391257695.18130.python-list@python.org> <roy-644DCB.09404301022014@news.panix.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 <roy-644DCB.09404301022014@news.panix.com>
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6280.1391267257.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On 01/02/2014 14:40, Roy Smith wrote:
> In article <mailman.6275.1391257695.18130.python-list@python.org>,
>   Ned Batchelder <ned@nedbatchelder.com> 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

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


Thread

Re: __init__ is the initialiser Ned Batchelder <ned@nedbatchelder.com> - 2014-01-31 14:52 -0500
  Re: __init__ is the initialiser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-01 03:42 +0000
    Re: __init__ is the initialiser Chris Angelico <rosuav@gmail.com> - 2014-02-01 15:35 +1100
      Re: __init__ is the initialiser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-01 05:51 +0000
        Re: __init__ is the initialiser Ethan Furman <ethan@stoneleaf.us> - 2014-02-01 00:28 -0800
    Re: __init__ is the initialiser Ethan Furman <ethan@stoneleaf.us> - 2014-01-31 20:55 -0800
    Re: __init__ is the initialiser Ned Batchelder <ned@nedbatchelder.com> - 2014-02-01 07:28 -0500
      Re: __init__ is the initialiser Roy Smith <roy@panix.com> - 2014-02-01 09:40 -0500
        Re: __init__ is the initialiser Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-01 15:07 +0000
          Re: __init__ is the initialiser Roy Smith <roy@panix.com> - 2014-02-01 11:17 -0500
    Re: __init__ is the initialiser Tim Delaney <timothy.c.delaney@gmail.com> - 2014-02-02 07:09 +1100
      Re: __init__ is the initialiser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-02 01:28 +0000
    Re: __init__ is the initialiser Ben Finney <ben+python@benfinney.id.au> - 2014-02-02 15:27 +1100
    Re: __init__ is the initialiser Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-03 12:38 +1300
      Re: __init__ is the initialiser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-03 00:33 +0000
        Re: __init__ is the initialiser Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-04 12:47 +1300
    Re: __init__ is the initialiser Tim Delaney <timothy.c.delaney@gmail.com> - 2014-02-03 11:02 +1100

csiph-web