Why isn't there a state.get? #2389
HHongSeungWoo
started this conversation in
General
Replies: 2 comments 13 replies
-
@Kludex do you see any reason not to make state a UserDict or make it implement the full MutableMapping API? |
Beta Was this translation helpful? Give feedback.
13 replies
-
Should be done before 1.0 IMHO. Been a pet peeve of mine for ages. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am interested in using state to manage shared variables that are valid only in specific contexts.
The issue I'm encountering here is that due to certain attributes being optionally present, I hope to retrieve them using a form similar to dict.get(key, defaultvalue).
However, as only __getattr__ is exposed, this approach is not feasible.
The alternative is to use getattr or try-except, but this may lead to code becoming unnecessarily messy or encountering performance issues.
Here's my test code:
What do you think about exposing the get method in the state
Beta Was this translation helpful? Give feedback.
All reactions