wouldn't you use a state change? Use a variable to indicate which function you want the first class to do
On Mon, Jan 19, 2009 at 6:31 PM, James Mills <prolo...@shortcircuit.net.au>wrote: > On Tue, Jan 20, 2009 at 10:08 AM, Astan Chee <astan.c...@al.com.au> wrote: > > Hi, > > I have two classes in python that are in two different files/python > scripts. > > Class A uses Class B like this: > > class B(object): > > def function1(self,something): > > pass > > def function2(self,something): > > print "hello one" > > print something > > > > class A(object): > > def __init__(self): > > instance = B() > > instance.function2("hello two") > > self.function3() > > def function3(self): > > print "hello three" > > def function3(self): > print "hello three" > self.instance.function1 = lambda x; x > > But you must bind instnace to self in B > > Modify your __init__ as follows: > > class A(object): > def __init__(self): > self.instance = B() > self.instance.function2("hello two") > self.function3() > > What's the use-case anyway ? > There might be a better way to solve your problem :) > > cheers > James > -- > http://mail.python.org/mailman/listinfo/python-list > -- "lalalalala! it's not broken because I can use it" http://linux.slashdot.org/comments.pl?sid=194281&threshold=1&commentsort=0&mode=thread&cid=15927703
-- http://mail.python.org/mailman/listinfo/python-list