Skip to content

Mutable object in function arguments #1

@shorodilov

Description

@shorodilov

def first_name_selection(names=[], gender='male', nationality='en'):

Please, do not use default mutable type objects in function arguments.
In case, you need to apply an empty list by default, there is a way to do this:

def some_func(default_empty_list = None):
    default_empty_list = defualt_empty_list or []

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions