On Sun, 19 Dec 2010 19:52:28 +0100
Eike Welk
My positive attitude towards this syntax comes from the only weakness that Python IMHO has: You can't easily see which data attributes an instance has. This information is hidden in __init__, and sometimes elsewhere.
Agreed. Rather commonly elsewhere, I guess.
I think a mechanism like slots should be the norm, and dynamism the exception.
I wish we could put in front place the set of intended data attributes, including ones w/o defaults and optional ones. Even better, instanciation with the same param names would automagically set those attributes. class Point(Object): x = 0 y = 0 d color def __init__(self, HLSColor=None): if color is not None: self.color = toRGB(color) self.d = self.x + self.y p = Point(x=1, y=2, color=HLS(0,0,50) assert (p.d == 3) (untested) I find those loads of "self.x=x" in constructors sooo stupid --I want the machine to do it for me. __init__ should only define the essential part of obj construction; while the final constructor would do some mechanical job in addition. Denis -- -- -- -- -- -- -- vit esse estrany ☣ spir.wikidot.com