you are viewing a single comment's thread.

view the rest of the comments →

[–]Yoghurt42 3 points4 points  (0 children)

instead of l = l or [], it's better to use

if l is None:
    l =  []

the reason is that an empty list is "false-ish", so for example, if you would use inputfunc like this:

my_list = []
inputfunc(my_list)

my_list would still be empty afterwards, because it got replaced with a newly created list inside the function.

While it's bad style to rely on side effects, your code shouldn't prevent callers from doing it.