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.

  • Doccool@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    11 days ago

    Oh wow! This would be great I really hope it’s accepted and implemented, makes a lot of sense!