On 4/4/07, Robert Kern <[EMAIL PROTECTED]> wrote: > Sebastian Haase wrote: > > Hello Gael, > > > > Short question regarding your tutorial -- I'm very intrigued by traits > > and would like to use them too .... > > Why do you define e.g. the Point class like this: > > class Point(object): > > """ 3D Point objects """ > > x = 0. > > y = 0. > > z = 0. > > > > and not like this: > > class Point(object): > > """ 3D Point objects """ > > def __init__(self): > > self.x = 0. > > self.y = 0. > > self.z = 0. > > > > I thought in the first case, if one did "a = Point(); a.x = 6" that > > from then on ANY new point ( "b = Point()" ) would be created with b.x > > being 6 -- because 'x' is a class attribute and nor a instance > > attribute !? > > No, setting "a.x = 6" will set it on the instance, not the class.
OK, but what is "wrong" with the first way !? I mean, it somehow seems not like "it's usually done" in Python ? Normally there is always a __init__(self) that sets up everything referring to self -- why is this tutorial doing it differently ? -Sebastian _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion