BadPython.com

Suggestion for "Default argument"

No mutable defaults!!!
            
def my_function(keyword_arg=None):
    """keyword_arg is a mutable list that persists 
       across invocations of my_function().
    """
    if keyword_arg is None:
        keyword_arg = []
    keyword_arg.append(1)
    return keyword_arg

assert(my_function() == [1])
assert(my_function() == [1]) # False: [1, 1] != [1]