On 2017-06-06, Deborah Swanson <pyt...@deborahswanson.net> wrote: >> I too have sometimes started with a namedtuple and then found >> I needed to make changes to the records. I typically abandon >> namedtuple at this point, after only one bad experience trying >> to work around my choice of container. > > I can appreciate that reaction. > > Guess I'm a bit of a bulldog though (right ot wrong), and the > concept of namedtuples is so ideally suited for the Excel > spreadsheet conversions I'm working on, I'll keep on pushing > the boundaries to see how they can be made to work. ;)
The namedtuple has found a happy place in my repertoire as the return value of functions that transform external read-only tabular data into a convenient form for lookup. I agree pushing a language feature beyond its preferable use cases is a good way to learn concepts and illuminate dark corners of both my own skill and Python's features. An Excel spreadsheet that represents a table of data is fairly simple to map onto a Python dict. One nearly codeless way is to export it from Excel as a csv file and then read it with csv.DictReader. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list