Popular recipes tagged "self" but not "readonly"http://code.activestate.com/recipes/tags/self-readonly/2017-04-26T17:26:29-07:00ActiveState Code RecipesAuto assign self attributes in __init__ using PEP 484 (Python) 2017-04-26T17:26:29-07:00Ryan Gonzalezhttp://code.activestate.com/recipes/users/4187447/http://code.activestate.com/recipes/580790-auto-assign-self-attributes-in-__init__-using-pep-/ <p style="color: grey"> Python recipe 580790 by <a href="/recipes/users/4187447/">Ryan Gonzalez</a> (<a href="/recipes/tags/annotations/">annotations</a>, <a href="/recipes/tags/class/">class</a>, <a href="/recipes/tags/self/">self</a>, <a href="/recipes/tags/type/">type</a>). Revision 2. </p> <p>TL;DR: Short way of doing stuff like <code>def __init__(self, a, b): self.a = a; self.b = b</code>, using type annotations from PEP 484, inspired by Dart's <code>MyConstructor(this.a, this.b)</code> and Ruby's/Crystal's/(Moon|Coffee)Script's <code>constructor/initialize(@a, @b)</code>.</p>