| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -973,10 +973,17 @@ def __delitem__(self, key): del self.data[key] | |
| def __iter__(self): | ||
| return iter(self.data) | ||
|
|
||
| # Modify __contains__ to work correctly when __missing__ is present | ||
| # Modify __contains__ and get() to work like dict | ||
| # does when __missing__ is present. | ||
| def __contains__(self, key): | ||
| return key in self.data | ||
|
|
||
| def get(self, key, default=None): | ||
| if key in self: | ||
|
Comment thread
bharel marked this conversation as resolved.
|
||
| return self[key] | ||
| return default | ||
|
|
||
|
Comment thread
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityNit: Only one blank line so as to match the surrounding code.
Sorry, something went wrong.
All reactions
|
||
|
|
||
| # Now, add the methods in dicts but not in MutableMapping | ||
| def __repr__(self): return repr(self.data) | ||
| def __copy__(self): | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Fixed :meth:`collections.UserDict.get` to not call | ||
| :meth:`__missing__` when a value is not found. This matches the behavior of | ||
| :class:`dict`. Patch by Bar Harel. |
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityAdd a comment that get() is overridden to avoid a False positive when _missing_ is defined.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.