[Python-ideas] namedlist() or Record type
Eric V. Smith
eric at trueblade.com
Wed Jul 24 15:28:23 CEST 2013
On 07/24/2013 08:54 AM, Steven D'Aprano wrote:
> On 24/07/13 17:50, anatoly techtonik wrote:
>> Rationale: There are many 2D data with table layout where order is
>> important and it is hard to work with them in Python.
> [...]
>
> It sounds to me that what you want is a mutable namedtuple. At least,
> that's what I often want. namedtuple was a fantastically useful addition
> to the standard library, I think a mutable record type would be too.
There are a number of implementations of this on PyPi, and probably
elsewhere. Here's one I wrote:
https://pypi.python.org/pypi/recordtype/
It could use some polishing. I don't particularly like that it conflates
mutability along with default parameters, but I couldn't think of an
easy way to separate them, and for my particular use I needed both.
Eric.
More information about the Python-ideas
mailing list