Python Forum
TypeError: 'dict_items' object does not support indexingw
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: 'dict_items' object does not support indexingw
#4
(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.
Reply


Messages In This Thread
RE: TypeError: 'dict_items' object does not support indexingw - by Skaperen - May-06-2022, 10:52 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020