On 13 Jul 2020, at 05:55, Christopher Barker
In fact, I doubt there are many uses
at all for dict.keys() -- most uses can jsut use the dict.
But you could use items() instead:
for name, val in sorted(dict.items()):
Sure. But my point was that the dict_keys object is very often unnecessary, not that all the views aren't useful. And it really is mostly only there for symmetry with dict_items(), which IS needed.
I'm on the fence though -- I think it adds clarity, even if it's unnecessary.
Christopher Barker, PhD
Python Language Consulting
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython