model: Fix mutable default parameters
Currently, we use lists in many places as default initializer parameters. In Python, this means, that each call to this initializer without an explicit specification of that parameter will receive a reference to the same list. Thus all those objects will use the same list of elements; adding an element to one of the objects will also add it to all other objects.
For some of our list attributes (all lists of Referable
s, forming Namespace
s), this will be fixed by #8 (closed). In all other cases, we should fix this by changing the default parameter to None
and adding the following code to the initializer:
if var is None:
var = []
This way, we create a new list for every default-initialized object.