[Python-ideas] A mutable alternative to namedtuple
anatoly techtonik
techtonik at gmail.com
Wed Mar 18 07:05:12 CET 2015
On Tue, Mar 17, 2015 at 7:52 PM, Luciano Ramalho <luciano at ramalho.org> wrote:
> Sometimes we need a simple class to hold some mutable attributes,
> provide a nice repr, support == for testing, and support iterable
> unpacking
+1, but I think that the core problem with such proposals is that they
lack the use cases. The only reason for me to have such class is to
work with tabular data.
For example, for querying the capability of the system, I need to build
an inmemory table of features, and then set parameters for each
feature one by one. sqlite/SQL is an overkill for that, and dicts are
just not enough to do readable lookups and updates to specific
cells, so I'd more appreciate a full table class than just its "named
row" model.
Practical example that I came up with:
https://bitbucket.org/techtonik/discovery/src/c4f3d306bb43772dcf3c03be8db941ff67d077b4/graphics/canvas2d/canvas2d/__init__.py?at=default#cl-22
--
anatoly t.
More information about the Python-ideas
mailing list