AttrDict icon indicating copy to clipboard operation
AttrDict copied to clipboard

inherit from OrderedDict instead of dict?

Open timodonnell opened this issue 9 years ago • 3 comments

Would be nice to maintain order. Could be an option, or just always inherit from OrderedDict.

timodonnell avatar May 22 '15 03:05 timodonnell

I second this request. Use case: I'm loading data from a CSV file, with the intent of writing back and leaving the column order undisturbed.

I just don't know enough about how dicts/ordereddicts work internally to be sure that there's no hidden pitfall with inheriting from OrderedDict.

andrew-vant avatar Jun 12 '15 15:06 andrew-vant

@andrew-vant, in the case of reading/writing CSV, I'd suggest you to use a tool created for it. ;-) I'm working on a new API implementation of my library rows and it does everything you need so you don't need to think in the details. It automatically identify and convert all the types to native Python types and gives you high-level objects instead of just strings. I'm planning to release this new API on PyPI later this month.

I'll add support to use AttrDict and other classes (instead of collections.namedtuple, the default by now) and you can follow the development in this issue: https://github.com/turicas/rows/issues/30

turicas avatar Jun 12 '15 18:06 turicas

There is always this, https://pypi.python.org/pypi/orderedattrdict but it would be nicer to have an OrderedAttrDict option in this library rather than relying on another independent implementation.

pansapiens avatar Aug 31 '17 00:08 pansapiens