Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76883

Re: Why can not initialize the class?

Newsgroups comp.lang.python
Date 2014-08-23 10:25 -0700
References (2 earlier) <53F756BF.1030100@gmail.com> <CAPM-O+wJi-ZLUyP+E=9DP+gje8k0O04nP6yuhrG75f2oQTMJZQ@mail.gmail.com> <mailman.13293.1408719557.18130.python-list@python.org> <53f75f22$0$6512$c3e8da3$5496439d@news.astraweb.com> <mailman.13318.1408750213.18130.python-list@python.org>
Message-ID <4d1aa42e-115b-446a-8ee5-dce92450cca2@googlegroups.com> (permalink)
Subject Re: Why can not initialize the class?
From CHIN Dihedral <dihedral88888@gmail.com>

Show all headers | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Why can not initialize the class? luofeiyu <elearn2014@gmail.com> - 2014-08-22 22:58 +0800
  Re: Why can not initialize the class? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-23 01:17 +1000
    Re: Why can not initialize the class? luofeiyu <elearn2014@gmail.com> - 2014-08-23 07:29 +0800
      Re: Why can not initialize the class? CHIN Dihedral <dihedral88888@gmail.com> - 2014-08-23 10:25 -0700
        Re: Why can not initialize the class? Michael Torrie <torriem@gmail.com> - 2014-08-23 20:03 -0600
    Re: Why can not initialize the class? alex23 <wuwei23@gmail.com> - 2014-08-25 16:33 +1000

csiph-web