[Solved] PEP 8 warning “Do not use a lambda expression use a def” for a defaultdict lambda expression [duplicate]

A lambda in Python is essentially an anonymous function with awkward restricted syntax; the warning is just saying that, given that you are assigning it straight to a variable – thus giving the lambda a name -, you could just use a def, which has clearer syntax and bakes the function name in the function … Read more

[Solved] defaultdict key default value issues

I am guessing, that the defaultdict is not what you want to use. Default values should be declared in the second argument of the get method. problem = [{‘lastInspection’: {‘date’: ‘2018-01-03’}, ‘contacts’: []}] default_inspection = { ‘date’: ‘2018-01-03’ } for p in problem: # default_inspection is returned, when ‘lastInspection’ is not present in the json … Read more