madpython a écrit : > Marc 'BlackJack' Rintsch wrote: > >>In <[EMAIL PROTECTED]>, madpython >>wrote: >> >> >>No it's not the normal way. Why don't you give `c` as argument to the >>`interClassCall()`? >> >>class B(object): >> def interClassCall(self, c): >> print c.a.a() >> >>class C(object): >> def __init__(self): >> self.a=A() >> self.b=B() >> def c(self): >> self.b.interClassCall(self) >> >>Much less magic involved this way. > > As far as I remember what you suggest would be perfect solution for > Java.
And for any other language, be it OO, functional or strictly procedural. > In other words it's a matter of getting a reference to "a" > (the instance of class A) and your variant just one of the others > possible. Maybe I came up with not very good example, so maybe I try to > explain it verbally. > As I already have written I play with Tkinter and make an application > that does some stuff. It uses dynamic GUI building depending on data it > process. Also one of the requriments is to separate the program logic > from GUI. Separating program logic from presentation is not excuse to write bad code. > Here is a short illustration: > > ... > self.b=Tkinter.Button(root,txt="Button",command=self.doSmth).pack() > self.l=Tkinter.Label(root,txt="default").pack() > def doSmth(self): > var=globals()["m"].__dict__["progLogic"].func("some > input") Yuck++ > self.l.config(txt=var) > self.l.update_idletasks() > ... > I guess it's all correct It's an horror. > or at least it close to what I work on. What > do you think? I think that it's an horror. > If I may I'd say it again that GUI is built according by > the data that's passed by the "thinking" part of the program It's not "passed". > so I > don't necessary know what it is What is polymorphism for ? > (can only guess) You don't have anything to guess. Just to learn what "design" means. > and that's why passing > references as an argument doesn't seem possible. Then you have a problem with your design. FWIW, decoupling presentation from program logic is nothing new - it has been solved *many* years ago. Google for MVC. -- http://mail.python.org/mailman/listinfo/python-list