![]() |
AttributeError: 'module' object has no attribute 'error'
I am puzzled as to why this program is throwing an
AttributeError: 'module' object has no attribute 'error' This example is right out of http://www.artima.com/weblogs/viewpost.jsp?thread=4829 I would appreciate any thoughts as to what the problem might be. tnx cmn #!/usr/bin/python """Module docstring. This serves as a long usage message. """ import sys import getopt def main(): # parse command line options try: opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) except getopt.error, msg: print msg print "for help use --help" sys.exit(2) # process options for o, a in opts: if o in ("-h", "--help"): print __doc__ sys.exit(0) # process arguments if __name__ == "__main__": main() |
Quote:
This is on Python 2.5.2. What version of python did you use? Is your python installation messed up? Since on your system it does no throw an error on importing getopt, but then later it does on getopt.error. That makes me think there could be something wrong with your getopt module. Or an incompatible version or so. BTW would you please use post code inside [ code ] and [ /code ] tags? On python code this is even more important than any other programming language, since indention matters with python. |
| All times are GMT -5. The time now is 05:00 PM. |