(answering to the op)
Cloudthunder wrote:
> How can I set up method delegation so that I can do the following:
> A.run()
> and have this call refer to the run() method within the boo instance? Also,
> what if I have tons of functions like run() within the boo instance and I
> want all them to be
> Are you sure you don't want to use a child class for this?
Composition/delegation introduce far less coupling than implementation
inheritance. Inheritance abuse is in fact a well-known OO antipattern.
Since Python makes delegation easy as pie, I don't see any reason to go
for inheritence when it
Cloudthunder wrote:
> How can I set up method delegation so that I can do the following:
>
> A.run()
>
> and have this call refer to the run() method within the boo instance? Also,
> what if I have tons of functions like run() within the boo instance and I
> want all them to be directly accessib
In the example:class Boo: def __init__(self, parent): self.parent = parent print self.parent.testme def run(): print "Yaho!"
class Foo: testme = "I love you!"
def __init__(self): test = Boo(self)A = Foo()How can I set up method delegation so that I can d
One way:
class Boo:
def __init__(self, parent):
self.parent=parent
class Foo:
X=1
def __init__(self):
self.test=boo(self)
--
http://mail.python.org/mailman/listinfo/python-list
I have two classes. I later create instances. One class creates an instance of the other class within itself. My question, is how does the child access the parent's properties, since it doesn't know ahead of time that it's going to be "adopted"? Example:
class Boo: passclass Foo: X = 1 __i