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
Marshall Tigerus
3,76211 gold badges40 silver badges71 bronze badges
1 Answer 1
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
user2555451
Sign up to request clarification or add additional context in comments.
1 Comment
Marshall Tigerus
@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.
lang-py
)on previous line.