Skip to content

Vector: Mutable default argument #762

@areebbeigh

Description

@areebbeigh

def __init__(self,components=[]):
"""
input: components or nothing
simple constructor for init the vector
"""
self.__components = list(components)

this should be something like

     def __init__(self,components=None): 
         """ 
             input: components or nothing 
             simple constructor for init the vector 
         """ 
         self.__components = [] if not components else list(components) 

https://docs.python-guide.org/writing/gotchas/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions