fix python example

This commit is contained in:
Jan Tattermusch 2015-07-20 14:34:27 -07:00
parent 78709f20fb
commit b95670f5fb
2 changed files with 5 additions and 5 deletions

View file

@ -19,7 +19,7 @@ def PromptForAddress(person):
if number == "":
break
phone_number = person.phone.add()
phone_number = person.phones.add()
phone_number.number = number
type = raw_input("Is this a mobile, home, or work phone? ")
@ -50,7 +50,7 @@ except IOError:
print sys.argv[1] + ": File not found. Creating a new file."
# Add an address.
PromptForAddress(address_book.person.add())
PromptForAddress(address_book.persons.add())
# Write the new address book back to disk.
f = open(sys.argv[1], "wb")

View file

@ -7,13 +7,13 @@ import sys
# Iterates though all people in the AddressBook and prints info about them.
def ListPeople(address_book):
for person in address_book.person:
for person in address_book.persons:
print "Person ID:", person.id
print " Name:", person.name
if person.HasField('email'):
if person.email != "":
print " E-mail address:", person.email
for phone_number in person.phone:
for phone_number in person.phones:
if phone_number.type == addressbook_pb2.Person.MOBILE:
print " Mobile phone #:",
elif phone_number.type == addressbook_pb2.Person.HOME: