When I make the "data" variable a class variable, the following works, but when I make it an object variable, the descriptor is not called. Please help.
class Data(object):
products = {
'milk': {'price': 1.50, 'quantity': 10},
'eggs': {'price': 0.20, 'quantity': 100},
'cheese': {'price': 2.00, 'quantity': 10}
}
def __get__(self, obj, klas):
print "Here in descriptor"
return self.products
class BusinessLogic(object):
def __init__(self): # When I remove these 2 lines
self.data = Data()
#data = Data() # and enable this line it does work !
def main():
b = BusinessLogic()
b.data
if __name__ == '__main__':
main()