VNG-Realisatie / vng-api-common

Gedeelde code voor RESTful APIs
5 stars 12 forks source link

Update kwargs.get call #137

Closed shea-maykinmedia closed 4 years ago

shea-maykinmedia commented 4 years ago

A bit of an odd quirk on python's dictionary get method is that a function specified in the second argument is run even if the key exists in the dictionary.

Eg.

>>> a_dict = {'key': 'value'}
>>> def print_thing():
...   print('thing')
... 
>>> a_dict.get('key', print_thing())
thing
'value'
>>> 

since it's better that get_default_base_name only runs when it's needed, since it can raise an exception, I think it's better to use or in this case.

I didn't add any unit tests for this PR because it would only be testing python's built in functionality but if you think a unit test or two would be useful I can add it.