On Nov 30, 2019, at 20:21, Wes Turner <wes.tur...@gmail.com> wrote: > > What about keys that contain invalid characters for attribute names?
What about them? > items = {'1': 1, 'two-3': 4,} > x = object() > x.__dict__.update(items) # dangerous > x = AttrDict(**items) > x.1 # error > x.two-3 # error The message you quoted was about how in Python 2 (but not 3) you could destructure parameters: sorted({1:300, 2:4}.items(), key=lambda (key, value): value) The wider discussion is about how if items() were a view of namedtuples instead of just sequences you could do something even better: sorted({1:300, 2:4}.items(), key=lambda it: it.value) What does either of those have to do with using a dict whose keys are not identifiers as an attribute dictionary for an object? Neither restoring Python 2’s parameter destructuring nor making items namedtuples would in any way affect any of the code you wrote. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/XR6ICESOS6SMXL3L3R2EKCMCWKTNE6CY/ Code of Conduct: http://python.org/psf/codeofconduct/