Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
The cheat sheet from the docs shows the following:
# Mapping describes a dict-like object (with "__getitem__") that we won't # mutate, and MutableMapping one (with "__setitem__") that we might def f(my_dict: Mapping[int, str]) -> List[int]: return list(my_dict.keys()) f({3: 'yes', 4: 'no'}) def f(my_mapping: MutableMapping[int, str]) -> Set[str]: my_mapping[5] = 'maybe' return set(my_mapping.values()) f({3: 'yes', 4: 'no'})
In both cases, the argument passed to f is a dict, though in one case the argument is annotated as Mapping and in the other MutableMapping.
f
dict
Mapping
MutableMapping
From this example, it might not be clear to a beginner when to use Mapping over MutableMapping.
The text was updated successfully, but these errors were encountered:
Good point! Would you like to submit a PR improving it?
Sorry, something went wrong.
Sure! I'll get to work
Successfully merging a pull request may close this issue.
The cheat sheet from the docs shows the following:
In both cases, the argument passed to
f
is adict
, though in one case the argument is annotated asMapping
and in the otherMutableMapping
.From this example, it might not be clear to a beginner when to use
Mapping
overMutableMapping
.The text was updated successfully, but these errors were encountered: