by d0mine · 4y ago · 0 comments
Python really needs something like:
{foo: "default", mapping} = mapping foo = mapping.pop("foo", "default")
It removes "foo" key from mapping if any. `foo` is "default" if "foo" is missing and `mapping["foo"]` otherwise.Dictionary unpacking compatible with the match/case syntax could look like:
{"foo": foo, **rest} = mapping
It asserts that there is "foo" key in mapping and puts its value into `foo`.