0

I'm getting the following error:

File "Question2.py", line 18
 except getopt.GetoptError as e:
SyntaxError: invalid syntax

Section of code that it comes from:

 try:
 opts, args = getopt.getopt(argv, "c:t:", ["class=","term="]
 except getopt.GetoptError as e:
 print 'Question2.py -c <class> -t <term>'
 system.exit(2)
 for opt, arg in opts:
 if opt in ('c', 'class'):
 selectclass = arg
 if opt in ('t', 'term'):
 selectterm = arg

What I am trying to do is get command line arguments working. I want to be able to accept -c or -class and -t or -term. I am following a tutorial located here. I am unsure what is going wrong.

asked Oct 14, 2013 at 19:11
1
  • 1
    Missing ) on previous line. Commented Oct 14, 2013 at 19:12

1 Answer 1

2

You forgot a closing parenthesis at the end of this line:

opts, args = getopt.getopt(argv, "c:t:", ["class=","term="])
# here--^
answered Oct 14, 2013 at 19:12
Sign up to request clarification or add additional context in comments.

1 Comment

@SethMMorton when I said that I had an 11m timer left on being able to. I hadn't gotten back on SO until just now.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.