Namedtuples: some unexpected inconveniences
python at deborahswanson.net
Fri Apr 14 20:24:58 EDT 2017
Gregory Ewing wrote, on Thursday, April 13, 2017 12:17 AM
> Deborah Swanson wrote:
> > But I think you got it right in your last sentence below.
> > copied them because they were immutable,
> No, definitely not. A defaultdict will never take it upon
> itself to copy an object you give it, either as a key or a value.
> The copying, if any, must have occurred somewhere else, in
> code that you didn't show us.
> Can you show us the actual code you used to attempt to
> update the namedtuples?
I think you've heard my sob story of how the actual code was lost
(PyCharm ate it).
I've made some attempts to recover that code, but honestly, at this
point Peter Otten has showed my enough examples of getattr() that work
with namedtuples with variable names, that I'd rather just accept that
probably some tranformation of the structure I did caused the copying of
values only. I remember looking at it in the debugger, but that code was
convoluted and I don't think it's worth teasing out exactly what went
wrong. (or figuring out how I did it in the first place)
More information about the Python-list