I've got a simple class setup here. What I want to happen is the 'print message' to be printed when I set the attribute 'info' of the class object Truck.
Nothing appears to be happening when I set the info property c.info = "Great"
I would expect it to print "this is being set"
# Classes
class Node(object):
def __init__(self, name, age):
self.name = name
self.age = age
class Truck(Node):
def __init__(self, name="", age=0):
super(Truck, self).__init__(name=name, age=age)
self.info = None
@property
def info(self):
return self.info
@info.setter
def info(self):
print "this is being set"
c = Truck()
c.info = "great"
print c.info