Last active
March 19, 2020 15:28
-
-
Save gmaze/509df67e6342394fbb266471eb984b16 to your computer and use it in GitHub Desktop.
Passing/merging options from function to subfunctions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def base_fct(**kwargs): | |
defaults = {'sharey':'row', 'dpi':80, 'facecolor':'w', 'edgecolor':'k'} | |
options = {**defaults, **kwargs} | |
return options | |
def fct(**kwargs): | |
defaults = {'sharey':'cols'} | |
return base_fct(**{**defaults, **kwargs}) | |
print("Default base options:\n", base_fct()) | |
print("Default fct options:\n", fct()) | |
print("Modified fct options:\n", fct(dpi=120)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a pattern I use a lot and keep looking around how to do it !