Skip to content

Instantly share code, notes, and snippets.

@chrisdel101
Last active August 8, 2022 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdel101/882ed4c9aaa7fe5a1a881d5de1f3133c to your computer and use it in GitHub Desktop.
Save chrisdel101/882ed4c9aaa7fe5a1a881d5de1f3133c to your computer and use it in GitHub Desktop.
Not pass in None kwargs to override default
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