I am trying to go from Python2
to Python3
. So the first step is to program forward compatible. Thus I use the from __future__
and the from builtins
imports. However this breaks slots.
While
class _Test(object):
__slots__ = ('a', )
test = _Test()
test.b = 1
raises an AttributeError
as expected
from builtins import object
class _Test(object):
__slots__ = ('a', )
test = _Test()
test.b = 1
just runs. Now test.__dict__
exists. So how can I use slots in Python3
?