[Tutor] Class attributes

Timothy M. Brauch tbrauch@mindless.com
Sun, 7 Jul 2002 02:16:03 -0400


I have read over the Reference Manual, but I am not sure if I understand
correctly.  Here is a short version of what I want.

Let's assume I have a class BigClass, and it has attributes such as
BigClass.a & BigClass.b

Below is what I would like for an interactive session (This is just made up
and not actual results)

IMAGINARY Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on
win32
IMAGINARY Type "copyright", "credits" or "license" for more information.
IMAGINARY IDLE Fork 0.8 -- press F1 for help
>>> c = BigClass()
>>> c.a = 'First'
>>> c.b = 'Second'
>>> print c
['First', 'Second']

I thought using __str__ inside BigClass would work, but appearently I was
wrong.  Is it possible to do what I want?

 - Tim

P.S. Is there a link to a page that describes all the __command__ I can add
to a class.  I just learned about __slots__ this past week, what else is
there?