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


Groups > comp.lang.python > #76790 > unrolled thread

Why can not initialize the class?

Started byluofeiyu <elearn2014@gmail.com>
First post2014-08-22 22:26 +0800
Last post2014-08-22 22:26 +0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Why can not initialize the class? luofeiyu <elearn2014@gmail.com> - 2014-08-22 22:26 +0800

#76790 — Why can not initialize the class?

Fromluofeiyu <elearn2014@gmail.com>
Date2014-08-22 22:26 +0800
SubjectWhy can not initialize the class?
Message-ID<mailman.13287.1408717593.18130.python-list@python.org>
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()

The error message is :
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "<stdin>", line 7, in __init__
   File "<stdin>", line 11, in set_email
TypeError: argument of type 'NoneType' is not iterable

What is wrong with the code?

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web