-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dict.pop() #1989
Comments
Hmm, so on second consideration, don't we want to have separate method for the get-with-default-value?? With the change as written in this issue and implemented in #1986, we end up having to None-check the result, even when we provide a default value - that seems suboptimal. Like I feel the whole idea with a default value is that we know we get a non-optional value back. We can never statically enforce the type to be non-optional for a single get method where the default argument is optional, so I guess we need separate methods? Something like this:
and similar for @sydow @nordlander @ddjoh WDYT? |
I agree, get with a default value is not the same as an optional get. One could merge the two by moving to the more elaborate signature
but that would require the planned support for unions as well as a lifted restriction in the constraint-solver. For later (perhaps). The only thing about adding |
I wouldn't read too much into the name. Can't say I would immediately feel getopt is more intuitive than getdef. I mean, sometimes you just have to learn what something means and not what you might guess from a few characters. |
We discussed adding .pop() to dict / Mapping in our weekly meeting.
We said we wanted this:
And these functions should not throw any exceptions - they should return None if the key is not found.
The text was updated successfully, but these errors were encountered: