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


Groups > comp.lang.python > #65219

Re: __init__ is the initialiser

From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: __init__ is the initialiser
Date 2014-02-01 15:07 +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>
Newsgroups comp.lang.python
Message-ID <mailman.6280.1391267257.18130.python-list@python.org> (permalink)

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