LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 04-09-2009, 05:03 PM   #1
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
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: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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



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



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:06 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration