Most viewed recipes tagged "self"http://code.activestate.com/recipes/tags/self/views/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>
ReadOnlyPrivateSingletonImplicitThisMetaClass (Python)
2010-05-10T08:34:32-07:00Chris Joneshttp://code.activestate.com/recipes/users/4171447/http://code.activestate.com/recipes/577221-readonlyprivatesingletonimplicitthismetaclass/
<p style="color: grey">
Python
recipe 577221
by <a href="/recipes/users/4171447/">Chris Jones</a>
(<a href="/recipes/tags/enterprise/">enterprise</a>, <a href="/recipes/tags/implicit/">implicit</a>, <a href="/recipes/tags/private/">private</a>, <a href="/recipes/tags/readonly/">readonly</a>, <a href="/recipes/tags/self/">self</a>, <a href="/recipes/tags/singleton/">singleton</a>).
Revision 3.
</p>
<p>Are you a totally agile rock star developer? Turn your code into a rock concert with this handy metaclass that makes your classes suitable for production deployment!</p>