Top-rated recipes tagged "collections", "abc", "dry", "shortcuts" and "inheritance"http://code.activestate.com/recipes/tags/collections+abc+dry+shortcuts+inheritance/top/2011-04-02T02:07:00-07:00ActiveState Code Recipesnamedtuple.abc - abstract base class + mix-in for named tuples (Python)
2011-04-02T02:07:00-07:00Jan Kaliszewskihttp://code.activestate.com/recipes/users/4172762/http://code.activestate.com/recipes/577629-namedtupleabc-abstract-base-class-mix-in-for-named/
<p style="color: grey">
Python
recipe 577629
by <a href="/recipes/users/4172762/">Jan Kaliszewski</a>
(<a href="/recipes/tags/abc/">abc</a>, <a href="/recipes/tags/collections/">collections</a>, <a href="/recipes/tags/dry/">dry</a>, <a href="/recipes/tags/inheritance/">inheritance</a>, <a href="/recipes/tags/namedtuple/">namedtuple</a>, <a href="/recipes/tags/shortcuts/">shortcuts</a>).
Revision 7.
</p>
<p>If you need</p>
<ul>
<li>to define <strong>named tuple subclasses</strong> (including reusable abstract ones), adding/overriding some methods, in a convenient way;</li>
<li>to have the named tuple ABC (abstract base class) for <strong>isinstance/issubclass</strong> tests;</li>
<li>or simply would like to define your named tuple classes in a <strong>class-syntax-based and DRY way</strong> (without repeating type names...)</li>
</ul>
<p>-- <strong>this recipe is for you.</strong></p>