Last active
August 8, 2022 16:13
-
-
Save chrisdel101/882ed4c9aaa7fe5a1a881d5de1f3133c to your computer and use it in GitHub Desktop.
Not pass in None kwargs to override default
This file contains hidden or 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 tester(paramA="Default Value"): | |
if paramA is None: | |
print('True') | |
else: | |
print('False') | |
def foo(**kwargs): | |
tester(kwargs.get('paramA')) | |
foo(paramA=None) ## True | |
## I cannot over write the default value but need to pass in the kwarg when it is not None. How? | |
## only option I can think of is this, which is horrible | |
# if kwargs.get('paramA')) == None: | |
# tester() | |
# else: | |
# tester(kwargs.get('paramA')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment