Printing getopt.GetoptError message?

Gustaf Liljegren gustafl at algonet.se
Sat Jun 2 08:45:51 EDT 2001


I'm trying to print the GetoptError message that I get if I don't use the 
try-except construction, but it won't work:

try:
  opts, args = getopt.getopt(sys.argv[1:], "c:d:h:")
except getopt.GetoptError:
  print getopt.GetoptError.msg
  sys.exit(2)

All I get is an empty string. What is wrong here?

Regards,

Gustaf Liljegren



More information about the Python-list mailing list