Some small suggestion: in the setter example the actual line of code that sets the Instance Member self.__captain = value is missing ;-)
classStarship:def__init__(self):# snip
self.__captain="Jean-Luc Picard"@propertydefcaptain(self):returnself.__captain@captain.setterdefcaptain(self,value):print("What do you think this is, "+value+", the USS Pegasus? Back to work!")uss_enterprise=Starship()print(uss_enterprise.captain)uss_enterprise.captain="Wesley"print(uss_enterprise.captain)
Resulting in this output, Jean-Luc Picard refuses to go away....
Thanks for the excellent Article.
Some small suggestion: in the
setter
example the actual line of code that sets the Instance Memberself.__captain = value
is missing ;-)Resulting in this output, Jean-Luc Picard refuses to go away....