Use __str__ for printing the contact information
Now that all the Contacts are an object we can just use __str__ to format them and pass that to print rather than use a print_contact() function Change-Id: I6cce8c08eaa19c06695a044da59ba75e671f3005
This commit is contained in:
parent
c582feffc0
commit
4b30a708eb
|
@ -32,11 +32,10 @@ class Contact(object):
|
|||
self.irc = contact_data['irc']
|
||||
self.email = contact_data['email']
|
||||
|
||||
|
||||
def print_contact(contact):
|
||||
print('Name : %s' % contact.name)
|
||||
print('IRC Nick : %s' % contact.irc)
|
||||
print('Email : %s' % contact.email)
|
||||
def __str__(self):
|
||||
return ("Name : {0.name}\n" +
|
||||
"IRC Nick : {0.irc}\n" +
|
||||
"Email : {0.email}").format(self)
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -75,6 +74,6 @@ def main():
|
|||
print(team_header)
|
||||
print('%s' % ('-' * len(team_header)))
|
||||
for contact in contacts:
|
||||
print_contact(contact)
|
||||
print(contact)
|
||||
|
||||
return 0
|
||||
|
|
Loading…
Reference in New Issue