<p dir="ltr"><br>
On Feb 14, 2013 6:20 AM, "Nick Coghlan" <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:<br>
> A recurring suggestion for collections.namedtuple is that it would be<br>
> nice to be able to define them like this (as it not only avoids having<br>
> to repeat the class name, but also allows them to play nicely with<br>
> pickle and other name-based reference mechanisms):<br>
><br>
> class MyTuple(collections.NamedTuple):<br>
> __fields__ = "a b c d e".split()</p>
<p dir="ltr">Something similar that I've been using:</p>
<p dir="ltr">@as_namedtuple("a b c d e")<br>
class MyTuple:<br>
"""My namedtuple with extra stuff."""<br>
@property<br>
def something_special(self):<br>
"""..."""<br>
return ...</p>
<p dir="ltr">Support for default values is also something I've added, but that's relatively orthogonal to this discussion.</p>
<p dir="ltr">-eric<br>
</p>