▲ 16 ▼ Avoiding boilerplate by using immutable default arguments (vulwsztyn.codeberg.page) submitted 1 year ago by Vulwsztyn@programming.dev to c/python@programming.dev 8 comments fedilink hide all child comments Hi, I recently realised one can use immutable default arguments to avoid a chain of: def append_to(element, to=None): if to is None: to = [] at the beginning of each function with default argument for set, list, or dict.
[–] Vulwsztyn@programming.dev [S] 3 points 1 year ago This is only a Draft for now though permalink fedilink source parent