defining class functions

Astan Chee astan.chee at al.com.au
Tue Jan 20 01:08:45 CET 2009


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"

What I want to do here is to (re)define function1 from function3. Is 
that possible? Is there any way of redefining a function of another 
class without inheriting it? Does this make sense?
Thanks
Astan



More information about the Python-list mailing list