> -----Original Message----- > From: Kirby Urner [mailto:[EMAIL PROTECTED] > > >>> class Angle (object): > > def __init__(self, thevalue): > self.value = float(thevalue) > > @property > def degrees(self): > return self.value > > @property > def radians(self): > return math.radians(self.value) > > >>> class Triangle (object): > > def __init__(self, A=30, B=60, C=90): > self.A = Angle(A) > self.B = Angle(B) > self.C = Angle(C)
Works for me. And I think pedagogically valuable as an approach. For an (embarrassingly) long time I had complicated my class hierarchies by not seeing the simple possibilities of creating classes to act as attributes of more far-reaching classes. Its simple and obvious - once it's simple and obvious. Downsides, warnings? Art _______________________________________________ Edu-sig mailing list [email protected] http://mail.python.org/mailman/listinfo/edu-sig
