Posts: 4,647
Threads: 1,494
Joined: Sep 2016
why does 'dict_items' not support indexing? this is the object type you get from dict.items(). shouldn't it interface like a tuple?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
May-06-2022, 10:52 PM
(This post was last modified: May-06-2022, 10:52 PM by Skaperen.)
(May-04-2022, 05:10 PM)ndc85430 Wrote: Presumably because the order of items isn't meaningful, in the same way it isn't meaningful for a dict.
because of the lack of indexing, it can't behave like a tuple and be used by code that intentionally accesses it with indexing for one of a few reasons i have come across even though in the case of dict.items, none of those reasons were involved. i ended up coding an almost duplicate function just to handle it as an iterator. what was being done need to do reverse-order access some segments of the tuples it got, and it needed to handle it with indexing to keep the access in sync.
the order of items in dict.items values truly had no meaning. but the code needed to handle it that way to avoid the duplication so that other cases that needed to, could use indexing.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.