Accessing object parent properties
Cloudthunder
digitalorganics at gmail.com
Tue May 23 14:27:56 EDT 2006
In the example:
class Boo:
def __init__(self, parent):
self.parent = parent
print self.parent.testme
def run():
print "Yahooooo!"
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 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 accessible as if they were part of their parent
(the Foo instance)?
Thanks!
On 5/23/06, Max Erickson <maxerickson at gmail.com> wrote:
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060523/39d92eef/attachment.html>
More information about the Python-list
mailing list