<div dir="ltr">Thanks everyone for the replies. <div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jan 16, 2014 at 1:36 AM, Cameron Simpson <span dir="ltr"><<a href="mailto:cs@zip.com.au" target="_blank">cs@zip.com.au</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 16Jan2014 15:53, Ben Finney <<a href="mailto:ben%2Bpython@benfinney.id.au">ben+python@benfinney.id.au</a>> wrote:<br>

> Roy Smith <<a href="mailto:roy@panix.com">roy@panix.com</a>> writes:<br>
> >  Ben Finney <<a href="mailto:ben%2Bpython@benfinney.id.au">ben+python@benfinney.id.au</a>> wrote:<br>
> > > Who says it's frowned on to do work in the initialiser? Where are they<br>
> > > saying it? That seems over-broad, I'd like to read the context of that<br>
> > > advice.<br>
> ><br>
> > There are some people who advocate that C++ constructors should not do<br>
> > a lot of work and/or should be incapable of throwing exceptions. The<br>
> > pros and cons of that argument are largely C++ specific. […]<br>
><br>
</div><div class="im">> Even simpler: They are mistaken in what the constructor is named, in<br>
> Python.<br>
> Python classes have the constructor, ‘__new__’. I would agree with<br>
> advice not to do anything but allocate the resources for a new instance<br>
</div>> in the constructor. [...]<br>
<div class="im">><br>
> Python instances have an initialiser, ‘__init__’. That function is for<br>
> setting up the specific instance for later use. This is commonly<br>
> over-ridden and many classes define a custom initialiser, which normally<br>
> does some amount of work.<br>
><br>
> I don't think ‘__init__’ is subject to the conventions of a constructor,<br>
> because *‘__init__’ is not a constructor*.<br>
<br>
</div>99% of the time this distinction is moot. When I call ClassName(blah,...),<br>
both the constructor and initialiser are called.<br>
<br>
Informally, there's a rule of thumb that making an object (allocate,<br>
construct and initialise) shouldn't be needlessly expensive. Beyond<br>
that, what happens depends on the use patterns.<br>
<br>
This rule of thumb will be what Rita's encountered, perhaps stated<br>
without any qualification regarding what's appropriate.<br>
<br>
Cheers,<br>
<span class="HOEnZb"><font color="#888888">--<br>
Cameron Simpson <<a href="mailto:cs@zip.com.au">cs@zip.com.au</a>><br>
<br>
The problem with keeping an open mind is that my ideas all tend to fall out...<br>
        - Bill Garrett <<a href="mailto:garrett@cs.unc.edu">garrett@cs.unc.edu</a>><br>
--<br>
<a href="https://mail.python.org/mailman/listinfo/python-list" target="_blank">https://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>--- <span>Get your facts first, then you can distort them as you please.</span>--
</div>