From: cgw at fnal.gov (Charles G Waldman)
Date: Mon, 5 Apr 1999 16:04:18 GMT
Subject: Subattributes of classes
In-Reply-To: <19990405104408.A807008@vislab.epa.gov>
References: <19990405104408.A807008@vislab.epa.gov>
Message-ID: <14088.57090.644687.407420@buffalo.fnal.gov>
X-UID: 1702                                                  

Randall Hopper wrote:

 > Why?

Because "attr" in class A is just an int, and has no attributes,
whereas "draw" in the Tkinter demo is a Canvas object, which has a
scrollX and scrollY attribute.

Consider this example:

class B:
    def __init__(self):
        self.subattr = None

class A:
    def __init__(self):
        self.attr = B()
        self.attr.subattr = 456

a = A()

print a.attr.subattr




