Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's wrong with my except? [duplicate]

I've got a SyntaxError on my except:

try:     opts, args = getopt.getopt(sys.argv[1:], 'P:D:H:d:u:p:nvhmJi:c:Ml:TB:',             ['host=', 'port=', 'directory=', 'user=', 'password=',              'daemon=', 'noauth', 'help', 'verbose', 'mysql',               'icounter=', 'config=', 'nolock', 'nomime', 'loglevel', 'noiter',              'baseurl=']) except getopt.GetoptError, e:     print usage     print '>>>> ERROR: %s' % str(e)     sys.exit(2) 

I get the error:

File "main.py", line 199  except getopt.GetoptError, e:  SyntaxError: invalid syntax 

Anyone have any idea?

like image 884
lagarkane Avatar asked Feb 16 '13 09:02

lagarkane


People also ask

Why is duplicate values not working?

Trailing or leading spaces Probably the most common cause of Excel not recognizing duplicates. Check if the one cell has trailing, leading or extra spaces in the cell. Excel sees the space as an individual character but humans tend to ignore it.

How do you exclude duplicates?

In Excel, there are several ways to filter for unique values—or remove duplicate values: To filter for unique values, click Data > Sort & Filter > Advanced. To remove duplicate values, click Data > Data Tools > Remove Duplicates.


1 Answers

You use python3 and in python3 the raise syntax no longer accepts comma-separated arguments.

Use as instead:

except getopt.GetoptError as e: 

This form is also backwards-compatible with 2.6 and 2.7.

like image 110
2 revs Avatar answered Sep 19 '22 15:09

2 revs