Accessing object parent properties

Cloudthunder digitalorganics at gmail.com
Tue May 23 08:27:35 EDT 2006


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:
    pass

class Foo:
    X = 1
    __init__(self):
        self.test = boo()


How in this case does the boo instance (self.test) access variable X? I need
to write a function in the Boo class that assume the Boo instance is going
to be instantiated within another class instance which will have certain
variables it needs to access. How do I do this? Am I making sense?

Thank you to anyone who can help.

- Cloudthunder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060523/c16bb9c8/attachment.html>


More information about the Python-list mailing list