I am currently wondering why this modest piece of code has an output I'm not expecting:
class Product(object):
price = 0
def __init__(self, tmp_price):
self.price = tmp_price
class Market(object):
products = []
def __init__(self):
self.products.append(Product(10))
a = Market()
b = Market()
print a.products[0]
print b.products[0]
print len(a.products)
Indeed, I get some output like:
<__main__.Product object at 0x7fe5899e46d0>
<__main__.Product object at 0x7fe5899e46d0>
2
Does anyone have an explanation? I guess it has something to do with python's way to handle references and all but...