oo problem

Tool69 kibleur.christophe at gmail.com
Sun Dec 10 04:46:22 EST 2006


Hi,
I've got a simple but difficult problem :

Suppose I've got a Paper class, on wich I can draw i.e a rectangle, a
circle or whatever.

class Paper(...):
    def __init__(self, paperx, papery):
        self.paperx = paperx
        self.papery = papery
        ....
    def draw(self, Primitive_Object):
        ....
class Rectangle(  ): <--- a Primitive_Object
    ...

Now, inside my Rectangle class, I need to recover the Paper instance
who called it (because I need the paper sizes to calculate something).
I now I can use a global variable, say " _paper" and then, inside  my
Paper.__init__() write something like this :

global _paper
_paper = [paperx,papery]

But it has drawbacks : what if I've got several Paper instances ?

I don't know if I'm clear enought, 
Thanks for your help :
6TooL9




More information about the Python-list mailing list