On Saturday, August 23, 2014 7:29:44 AM UTC+8, luofeiyu wrote: > One final version: > > > > class Contact(object): > > def __init__(self, email="haha@haha"): > > self.email = email > > def _get_email(self): > > return self._the_secret_private_email > > def _set_email(self, value): > > self.self._the_secret_private_email = value > > email = property(_get_email, _set_email) > > > > contact = Contact() > > print(contact.email) > > > > There is a little mistake here. It is > > > > self._the_secret_private_email = value > > > > not > > > > self.self._the_secret_private_email = value > > > > think for your demo .The value in `def _set_email(self, value):` is the value > of self.email .
Well, an object in python can add properties in the run-time to evolve steadily and stealthly. Those unnessary set-get-C++ methods are not very important in PYTHON. -- https://mail.python.org/mailman/listinfo/python-list