Very practical question
madpython
madpython at gmail.com
Wed Jul 5 12:45:13 EDT 2006
I've been doing an application with Tkinter widgets. Nothing really
fancy just routine stuff. Though I have no problems with it by now I
guess it would be reasonable to ask about a thing that's been bothering
me a bit. Look at this piece of code:
class A(object):
def a(self):
return "a from A"
class B(object):
def interClassCall(self):
print globals()['c'].__dict__['a'].a()
class C(object):
def __init__(self):
self.a=A()
self.b=B()
def c(self):
self.b.interClassCall()
if __name__=="__main__":
c=C()
c.c()
What is another way to get data from method of another instance of a
class? Or maybe print globals()['c'].__dict__['a'].a() is perfectly
normal. I need your professional expertise.
More information about the Python-list
mailing list