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 .
--
https://mail.python.org/mailman/listinfo/python-list