LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 04-09-2009, 05:03 PM   #1
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, Red Hat
Posts: 571

Rep: Reputation: 34
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()
 
Old 04-09-2009, 05:45 PM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,524

Rep: Reputation: 93
Quote:
Originally Posted by cmnorton View Post
I am puzzled as to why this program is throwing an

AttributeError: 'module' object has no attribute 'error'
I tried the program and on my python installation it doesn't throw any excpetion...

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.
 
  


Reply

Tags
attribute, error, python


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
wxpython: ListBox object has no attribute 'GetItems' browny_amiga Programming 6 04-10-2009 10:58 PM
python: AttributeError: 'list' object has no attribute 'Append' browny_amiga Programming 3 01-12-2009 04:58 AM
gentoo env-update AttributeError: 'module' object has no attribute 'env_update' linux_mopper Linux - Newbie 2 08-06-2008 01:20 PM
can javascript control the loop attribute of an embed object? BrianK Programming 3 06-27-2008 10:09 AM
perl install error: Can't locate object method "new" via package "Module::Build::Vers powah Linux - Software 0 10-24-2006 01:57 PM


All times are GMT -5. The time now is 02:56 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration