Subattributes of classes

Randall Hopper aa8vb at vislab.epa.gov
Mon Apr 5 10:44:08 EDT 1999


   class A:
     def __init__( self ):
       self.attr = 123
       self.attr.subattr = 456        # <--------- Error!

   a = A()


This generates an error as I would have expected.

However, I see the same syntax in:
   demos/tkinter/matt/canvas-with-scrollbars.py

and it works:

   self.draw = Canvas(self, width="5i", height="5i",
                      background="white",
                      scrollregion=(0, 0, "20i", "20i"))
   self.draw.scrollX = Scrollbar(self, orient=HORIZONTAL)
   self.draw.scrollY = Scrollbar(self, orient=VERTICAL)

        ^^^^^^^^^^^^

Why?

Randall







More information about the Python-list mailing list