What do you want this for? It may be hard to get you the best answer without knowing your exact intent.
It is almost always better to do this manually if you want to display an instance of your class in a specific way. This will include exactly what you want and not include what you don't want, and the order will be predictable.
If you are looking for a way to display the content of a class, manually format the attributes you care about and provide this as the __str__
or __repr__
method for your class.
If you want to learn about what methods and such exist for an object to understand how it works, use help
. help(a)
will show you a formatted output about the object's class based on its docstrings.
dir
exists for programatically getting all the attributes of an object. (Accessing __dict__
does something I would group as the same but that I wouldn't use myself.) However, this may not include things you want and it may include things you do not want. It is unreliable and people think they want it a lot more often than they do.
On a somewhat orthogonal note, there is very little support for Python 3 at the current time. If you are interested in writing real software you are going to want third-party stuff like numpy, lxml, Twisted, PIL, or any number of web frameworks that do not yet support Python 3 and do not have plans to any time too soon. The differences between 2.6 and the 3.x branch are small, but the difference in library support is huge.