How come this code runs for me?
class Foo():
__slots__ = []
def __init__(self):
self.should_not_work = "or does it?"
print "This code does not run,",self.should_not_work
Foo()
I thought slots worked as a restriction. I’m running Python 2.6.6.
The
__slots__mechanism works for new-style classes. You should inherit fromobject.Change the class declaration to