LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 12-07-2004, 04:28 PM   #1
clausawits
Member
 
Registered: Jun 2001
Posts: 147

Rep: Reputation: 16
Python and instance attributes


Hello, I'm modifying another person's python code for a toying/learning experience, and right now I am repeatedly getting the error:
Code:
AttributeError: 'FOO' object has no attribute 'BAR'
(sometimes 'FOO' is an instance rather than an object, if you want to quibble)
To which my response is generally-- 'It doesn't? I thought FOO had that.. what does FOO really have, then? Maybe FOO isn't all that I thought it was.'

So, what I would like to be able to do is put a line of text into the script that goes something like:
Code:
print alltheattributesofobject(FOO)
so I can see what stuff FOO does and does not have.. (attributes, methods, what have you).

Is there such a command? I've tried searching google for things like "list attributes of an instance" (in which I intend "list" to be considered a verb) but it always gives me results treating "list" as a noun, which is understandable, but unhelpful.

Any help? Many thanks...

Last edited by clausawits; 12-07-2004 at 04:29 PM.
 
Old 12-07-2004, 05:25 PM   #2
towlie
Member
 
Registered: Apr 2004
Location: U.S.
Distribution: slackware 10.0
Posts: 110

Rep: Reputation: 15
never tried this, but this is from python's site:


dir()???


http://docs.python.org/lib/specialattrs.html
 
Old 12-08-2004, 10:17 AM   #3
clausawits
Member
 
Registered: Jun 2001
Posts: 147

Original Poster
Rep: Reputation: 16
Many thanks! That seems to do the trick! My own prejudice tripped me up, I guess.. I would never have thought that the command I was looking for would be named dir().. I'm too used to it meaning a directory listing, and I don't think of objects/instances as directories.. :/ maybe my brain isn't sufficiently pythonized..

anyway, thanks again!
 
  


Reply


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Processing Conflict: python-devel conflicts python< 2.3.4-13.1 guarriman Fedora 2 04-23-2009 07:02 PM
Attributes - color satimis Linux - General 2 03-22-2005 10:39 PM
Kdesktop attributes rogere Linux - Software 0 12-15-2004 08:10 PM
thread attributes iftiuk Programming 2 07-29-2004 01:41 PM
Name the attributes alaios General 5 10-29-2003 06:50 PM

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

All times are GMT -5. The time now is 11:23 PM.

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