__slot__ issues
Arthur Siegel
ajs at ix.netcom.com
Thu Jul 4 23:44:55 EDT 2002
(The following is copy of my post to tutor at python.org.
Since I believe it to involve a (minor) bug issue, I
thought I'd copy it here for possible comment)
Apologies to the folks who do not share my new found interest in slots.
Which I am starting to think of as the quark of the Python object world.
>>> class A(object):
__slots__=("a")
>>> class B(A):
__slots__=("b")
>>> b=B()
>>> b.__slots__
'b'
>>> b.a=4
In other words "a" is somehow acting as a slot for
B instances, but is not *in* B.__slots__.
How would one then reference, introspect, whatever
as to what are in fact available slots for instances of B?
And a possibly minor bug:
>>> class A(object):
__slots__="a"
>>> class B(object):
pass
>>> class C(A,B):
__slots__=("b")
>>> c=C()
>>> c.a=1
>>> c.b=2
>>> c.c=3
Traceback (most recent call last):
File "<pyshell#12>", line 1, in ?
c.c=3
SystemError: C:\Code\221\Objects\dictobject.c:511: bad argument to internal
function
If B is a classic class and I do the same multi-inheritance I get the
expected error message:
AttributeError: 'C' object has no attribute 'c'
So its the error message, not the behavior that I am pointing to as probably
unintended.
Art
_______________________________________________
Tutor maillist - Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor
More information about the Python-list
mailing list