Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76967
| Date | 2014-08-25 09:45 +0200 |
|---|---|
| From | Antoon Pardon <antoon.pardon@rece.vub.ac.be> |
| Subject | Re: Why can not initialize the class? |
| References | <53F752FA.8080902@gmail.com> <lt8j8n$oau$1@ger.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13403.1408952782.18130.python-list@python.org> (permalink) |
On 23-08-14 01:20, Terry Reedy wrote:
> On 8/22/2014 10:26 AM, luofeiyu wrote:
>> System:win7+python34.
>> class Contact(object):
>> def __init__(self, first_name=None, last_name=None,
>> display_name=None, email=None):
>> 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):
>> if '@' not in value:
>> raise Exception("This doesn't look like an email
>> address.")
>> self._email = value
>> def get_email(self):
>> return self._email
>> email = property(get_email, set_email)
>> contact = Contact()
> By posting code with an extra indent, you make it imposible to run by
> just cutting and pasting. You should already know that.
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Why can not initialize the class? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2014-08-25 09:45 +0200
csiph-web