Why can not initialize the class?

CHIN Dihedral dihedral88888 at gmail.com
Sat Aug 23 13:25:19 EDT 2014


On Saturday, August 23, 2014 7:29:44 AM UTC+8, luofeiyu wrote:
> 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 .

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.



More information about the Python-list mailing list