Protcol Buffers - Python - Issue with tutorial -


context

issue

when run below file in python launchernothing 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:

enter image description here

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

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -