shanenin Posted August 28, 2005 Report Share Posted August 28, 2005 I am trying to figure out what is happening in the following codedef main(argv): grammar = "kant.xml" try: except getopt.GetoptError: usage() sys.exit(2) for opt, arg in opts: if opt in ("-h", "--help"): usage() sys.exit() elif opt == '-d': global _debug _debug = 1 elif opt in ("-g", "--grammar"): grammar = argin particular this line for opt, arg in opts:when ever I try to use similar syntax in my python interpreter I get this error>>> opts = ['j','h','f']>>> for i, y in opts:... print i...Traceback (most recent call last): File "<stdin>", line 1, in ?ValueError: need more than 1 value to unpack Quote Link to post Share on other sites
jcl Posted August 29, 2005 Report Share Posted August 29, 2005 (edited) opts is probably a list of pairs, e.g. [('foo', 'bar'), ('baz', 'fnord')]. Edited August 29, 2005 by jcl Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.