<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 26, 2017 at 11:17 AM, Erik <span dir="ltr"><<a href="mailto:python@lucidity.plus.com" target="_blank">python@lucidity.plus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div id="gmail-:1hv" class="gmail-a3s gmail-aXjCH gmail-m15baad6e2d98f737">I had forgotten that decorators could take parameters. Something like that pretty much ticks the boxes for me.<br></div></blockquote><div><br></div><div>There are decorators with "include" and "included" in this SO Q&A:</div><div><br></div><div> <a href="http://stackoverflow.com/q/3652851/545637">http://stackoverflow.com/q/3652851/545637</a><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div id="gmail-:1hv" class="gmail-a3s gmail-aXjCH gmail-m15baad6e2d98f737">
I'd _prefer_ something that sits inside the method body rather than just outside it, and I'd probably _prefer_ something that wasn't quite so heavyweight at runtime (which may be an irrational concern on my part ;)), </div></blockquote><div><br></div><div>The same strategies applied by the decorators may be applied by a by a function called from within __init__.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div id="gmail-:1hv" class="gmail-a3s gmail-aXjCH gmail-m15baad6e2d98f737">but those aren't deal breakers, depending on the project - and the vast majority of what I do in Python is short-lived one-off projects and rapid prototyping for later implementation in another language, so I do seem to be fleshing out a set of classes from scratch and writing a bunch of __init__ methods far more of the time than people with long-lived projects would do. Perhaps that's why it irritates me more than it does some others ;)</div></blockquote></div><div class="gmail_extra"><br></div>For the cases I've found in which classes define several attributes that are initialized in the constructor I think that a library like <a href="https://github.com/python-attrs/attrs">https://github.com/python-attrs/attrs</a> does what's needed. The downside is that code-writing tools (like IDEs) don't understand what's going on under the hood.<br clear="all"><div><br></div>-- <br><div class="gmail_signature"><span style="color:rgb(0,102,0)">Juancarlo </span><b style="color:rgb(0,102,0)">Añez</b></div>
</div></div>