examples:
def my_function(callback=None):
This is smelly because callback’s data type could be none or function. That’s not hard to get around but I know many consider this ambiguity a faux pas.
def my_function(callback=lambda x: None):
This seems smelly to me just because it’s creating a function inside the kwargs list – which is an unexpected place to instantiate anything other than numbers, bools, and empty strings.
Whaddaya think?
submitted by /u/OhGodSoManyQuestions
[link] [comments]
r/learnpython examples: def my_function(callback=None): This is smelly because callback’s data type could be none or function. That’s not hard to get around but I know many consider this ambiguity a faux pas. def my_function(callback=lambda x: None): This seems smelly to me just because it’s creating a function inside the kwargs list – which is an unexpected place to instantiate anything other than numbers, bools, and empty strings. Whaddaya think? submitted by /u/OhGodSoManyQuestions [link] [comments]
examples:
def my_function(callback=None):
This is smelly because callback’s data type could be none or function. That’s not hard to get around but I know many consider this ambiguity a faux pas.
def my_function(callback=lambda x: None):
This seems smelly to me just because it’s creating a function inside the kwargs list – which is an unexpected place to instantiate anything other than numbers, bools, and empty strings.
Whaddaya think?
submitted by /u/OhGodSoManyQuestions
[link] [comments]