We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I just learned what collections.ChainMap does, and one of the examples of its use is to manage overriding default keyword arguments, e.g.
collections.ChainMap
from collections import ChainMap class CRMUser(User): def __init__(self, name, component, **kwargs): defaults = {"user_id": next(component.user_id), "role": "read"} super().__init__(name, **ChainMap(kwargs, defaults))
where kwargs is optional, and if provided a key in kwargs will end up overriding the corresponding default key in defaults.
kwargs
defaults
We have this problem a lot in xGCM, with default kwargs that we allow the user to override. This pattern might simplify handling the options.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I just learned what
collections.ChainMap
does, and one of the examples of its use is to manage overriding default keyword arguments, e.g.where
kwargs
is optional, and if provided a key in kwargs will end up overriding the corresponding default key indefaults
.We have this problem a lot in xGCM, with default kwargs that we allow the user to override. This pattern might simplify handling the options.
The text was updated successfully, but these errors were encountered: