Why can not initialize the class?

luofeiyu elearn2014 at gmail.com
Fri Aug 22 19:29:44 EDT 2014


One final version:

class Contact(object):
     def __init__(self, email="haha at 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 .





More information about the Python-list mailing list