Was doing something this morning and thought this was weird. Why am I able to do this? I would think this should bounce back saying there is no rank attribute.
class EmployeeClass(object):
__status = None
def __init__(self, status):
self.__status = status
def get_status(self):
return self.__status
def set_status(self, status):
self.__status = status
John_Smith = EmployeeClass("Employed")
John_Smith.rank = 'Director'
print(John_Smith.rank)
This actually runs and returns "Director" to me. I don't quite understand that, this line should fail shouldn't it?
John_Smith.rank = 'Director'