[Tutor] Newbie class question

Alan Trautman ATrautman@perryjudds.com
Wed, 29 May 2002 17:33:55 -0500


All,

I am very frustrated so please bear with me:

I assume my problem is with the way classes interact in Python. My project
uses tree layers of identical objects using the instantion name to
differentiate them. 

The lowest class is color which is the most basic node consisting of data
elements and get functions. They are also private so entry can be
controlled.

There are 4 of these colors in a class side which also breaks down the
source file into the color info

There are then 4 sides in a larger unit which sort the data and pass it to
the side for processing

The problem occurs at the highest level the 4 side do not appear unique. If
I only fill one of the sides with four colours worth of data when I ask for
the elements that have been stored all 4 sides say they have the same data.
I have checked and the file converter is only being called once on the
correct side. That is why I conclude that I must not know something about
the way python handles data in classes and somehow these objects are not
being kept separate.

This is the class which appear to be interacting but I'm not sure at this
point

class Side:
    __filesadded = 0
    K = pjColour.Colour('Black')
    C = pjColour.Colour('Cyan')
    M = pjColour.Colour('Magenta')
    Y = pjColour.Colour('Yellow')

    def __init__(self):
        __filesadded = 0

Thank for all your help
Alan