[Tutor] slots - a more basic issue
Arthur Siegel
ajs@ix.netcom.com
Thu, 4 Jul 2002 12:20:20 -0400
Sorry for the multiple posts- but while the
fire's hot.
It now seems that I was misinterpreting slots in a more
basic way.
>>> class A(object):
__slots__=("x","y","color")
def __init__(self,x,y,**kws):
self.x=x
self.y=y
self.color=kws.get("color")
>>> a=A(1,2,color="green")
>>> a.color
'green'
>>> b=A(1,2,kolor="green")
>>> print b.color
None
My typo of "color" as "kolor" still passes silently.
How might I accomplish the control against such
typos that I thought slots were going to help me accomplish?
Art