Protcol Buffers - Python - Issue with tutorial -
context
- i'm working through tutorial: https://developers.google.com/protocol-buffers/docs/pythontutorial
- i've created files copy , pasting above tutorial
issue
when run below file in python launcher
nothing happens:
#! /usr/bin/python import addressbook_pb2 import sys # iterates though people in addressbook , prints info them. def listpeople(address_book): person in address_book.person: print "person id:", person.id print " name:", person.name if person.hasfield('email'): print " e-mail address:", person.email phone_number in person.phone: if phone_number.type == addressbook_pb2.person.mobile: print " mobile phone #: ", elif phone_number.type == addressbook_pb2.person.home: print " home phone #: ", elif phone_number.type == addressbook_pb2.person.work: print " work phone #: ", print phone_number.number # main procedure: reads entire address book file , prints # information inside. if len(sys.argv) != 2: print "usage:", sys.argv[0], "address_book_file" sys.exit(-1) address_book = addressbook_pb2.addressbook() # read existing address book. f = open(sys.argv[1], "rb") address_book.parsefromstring(f.read()) f.close() listpeople(address_book)
result:
question
- what steps should take work out issue?
that's not "nothing happens". got error message showing didn't call program correctly. specifically, didn't pass address book file use.
Comments
Post a Comment