Global variables within classes.

Donn Ingle donn.ingle at gmail.com
Fri Nov 9 20:09:38 CET 2007


Hi,
I'm getting myself really confused. I have three classes. Two of them need
to reference the third, like so:

Canvas ---> Stack <--- Thing

I am doing this right now:

s = Stack()

And then within <class Canvas:> I am referring directly to the global
variable 's' (and again from Thing).

Now, this works, but it bugs me somewhat. I don't want to limit a user to
having to declare a global variable of a particular name.
They should be able to say <Zombie = Stack()>

This may also leads to more confusion because the user can also make Things
directly <mything = Thing()> and I want the new things to all reference the
*same* Stack. (Right now it works because I reference 's' within Thing.)

I thought this might be a case for multiple inheritance but I just keep
getting recursion errors as one thing refers to another in a big mess.

Does that makes sense?

\d




More information about the Python-list mailing list