Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
b95670f5
Commit
b95670f5
authored
Jul 20, 2015
by
Jan Tattermusch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix python example
parent
78709f20
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
add_person.py
examples/add_person.py
+2
-2
list_people.py
examples/list_people.py
+3
-3
No files found.
examples/add_person.py
View file @
b95670f5
...
...
@@ -19,7 +19,7 @@ def PromptForAddress(person):
if
number
==
""
:
break
phone_number
=
person
.
phone
.
add
()
phone_number
=
person
.
phone
s
.
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
.
person
s
.
add
())
# Write the new address book back to disk.
f
=
open
(
sys
.
argv
[
1
],
"wb"
)
...
...
examples/list_people.py
View file @
b95670f5
...
...
@@ -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
.
person
s
:
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
.
phone
s
:
if
phone_number
.
type
==
addressbook_pb2
.
Person
.
MOBILE
:
print
" Mobile phone #:"
,
elif
phone_number
.
type
==
addressbook_pb2
.
Person
.
HOME
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment