Hello All,
Why is python designed so that b and c (according to code below)
actually share the same list object? It seems more natural to me that
each object would be created with a new list object in the points
variable.
class Blob:
def __init__(self, points=[]):
self._points = points
b = Blob()
c = Blob()
b._points.appen d(1)
c._points.appen d(2)
print b._points
# this will show that b._points is the same object as c._points
Why is python designed so that b and c (according to code below)
actually share the same list object? It seems more natural to me that
each object would be created with a new list object in the points
variable.
class Blob:
def __init__(self, points=[]):
self._points = points
b = Blob()
c = Blob()
b._points.appen d(1)
c._points.appen d(2)
print b._points
# this will show that b._points is the same object as c._points
Comment