-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Closed as not planned
Closed as not planned
Copy link
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
Description
How can I check if an object is a dict_keys()
in Python?
My current options are:
- seems bad style:
dict_keys = type(dict().keys())
is_dict_keys = isinstance(foo, dict_keys)
- overzealously matches:
from collections.abc import KeysView
is_dict_keys = isinstance(foo, KeysView)
There's no way to import this from the types
library and there's no documentation about it in the Dictionary view objects section of the documentation.
Is there a better way to do this? Is dict_keys
intentionally excluded from the documentation?
Metadata
Metadata
Assignees
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory