Subattributes of classes

Randall Hopper aa8vb at vislab.epa.gov
Mon Apr 5 12:20:58 EDT 1999


Christian Tismer:
 |>    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)
 |>         ^^^^^^^^^^^^
 |
 |This is since the self.draw is assigned a Canvas instance
 |which is itself an object with attributes.

Thanks to all who replied.  

I was foiled by "print self.draw" printing something that looked like a
primitive string type (the Tk widget name), and so I didn't think it was a
class and thus couldn't have attributes.  

I'll not forget __str__/__repr__ so easily next time. :-)

Thanks,

Randall





More information about the Python-list mailing list