mirror of
https://github.com/capnproto/pycapnp.git
synced 2025-03-04 08:24:43 +01:00
Update example in README to the new simplified interface for enums
This commit is contained in:
parent
07e9d370a9
commit
06f25852bc
1 changed files with 9 additions and 9 deletions
18
README.md
18
README.md
|
@ -51,7 +51,7 @@ def writeAddressBook(fd):
|
|||
bobPhones[0].number = "555-4567"
|
||||
bobPhones[0].type = 'home'
|
||||
bobPhones[1].number = "555-7654"
|
||||
bobPhones[1].type = addressbook.Person.PhoneNumber.Type.WORK
|
||||
bobPhones[1].type = 'work'
|
||||
bob.employment.unemployed = None
|
||||
|
||||
capnp.writePackedMessageToFd(fd, message)
|
||||
|
@ -71,14 +71,14 @@ def printAddressBook(fd):
|
|||
which = person.employment.which()
|
||||
print which
|
||||
|
||||
if which == addressbook.Person.Employment.Which.UNEMPLOYED:
|
||||
print 'unemployed'
|
||||
elif which == addressbook.Person.Employment.Which.EMPLOYER:
|
||||
print 'employer:', person.employment.employer
|
||||
elif which == addressbook.Person.Employment.Which.SCHOOL:
|
||||
print 'student at:', person.employment.school
|
||||
elif which == addressbook.Person.Employment.Which.SELF_EMPLOYED:
|
||||
print 'self employed'
|
||||
if which == 'unemployed':
|
||||
print('unemployed')
|
||||
elif which == 'employer':
|
||||
print('employer:', person.employment.employer)
|
||||
elif which == 'school':
|
||||
print('student at:', person.employment.school)
|
||||
elif which == 'selfEmployed':
|
||||
print('self employed')
|
||||
print
|
||||
|
||||
f = open('example', 'r')
|
||||
|
|
Loading…
Add table
Reference in a new issue