Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76797
| References | <53F752FA.8080902@gmail.com> <CACwCsY5P_8OUma6yMJxNCDd1WHtNrM0_ck2oebLv3mpPF20WCQ@mail.gmail.com> <53F756BF.1030100@gmail.com> <CAPM-O+wJi-ZLUyP+E=9DP+gje8k0O04nP6yuhrG75f2oQTMJZQ@mail.gmail.com> <53F75AA9.8010208@gmail.com> |
|---|---|
| Date | 2014-08-22 11:02 -0400 |
| Subject | Re: Why can not initialize the class? |
| From | Larry Martell <larry.martell@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13294.1408719768.18130.python-list@python.org> (permalink) |
On Fri, Aug 22, 2014 at 10:58 AM, luofeiyu <elearn2014@gmail.com> wrote: >>>> class Contact(object): > ... def __init__(self, first_name=None, last_name=None, > ... display_name=None, email="haha@haha"): > ... self.first_name = first_name > ... self.last_name = last_name > ... self.display_name = display_name > ... self.email = email > ... def print_info(self): > ... print(self.display_name, "<" + self.email + ">" ) > ... def set_email(self, value): > ... print(value) > ... self._email = value > ... def get_email(self): > ... return self._email > ... email = property(get_email, set_email) > ... >>>> >>>> contact = Contact() > haha@haha > > why the value in `def set_email(self, value): ` is haha@haha? > how haha@haha is called to value in `def set_email(self, value): `? > would you mind telling me the process? https://docs.python.org/3.4/library/functions.html#property
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Why can not initialize the class? Larry Martell <larry.martell@gmail.com> - 2014-08-22 11:02 -0400
csiph-web