Sunday 27 December 2020

Pass **kwargs if not none

I would use either

html.append(self.render_option(val, label, selected, **(other or {})))

or

html.append(self.render_option(val, label, selected, **(other if other is not None else {})))

or the more explicit

if other is None:
    other = {}
html.append(self.render_option(val, label, selected, **other))

Passing an empty dict as kwargs should be the same as not specifying kwargs.


from : https://stackoverflow.com/questions/23484091/pass-kwargs-if-not-none 

No comments:

Post a Comment