You then have to initialize your class in a traditional way. It will work like this :
class Empty:
__slots__ =()
def mkEmpty():
return Empty()
class NonEmpty():
__slots__ = ('one', 'two')
def __init__(self, one, two):
self.one = one
self.two = two
def mkNonEmpty(one, two):
return NonEmpty(one, two)
Actually, the constructor functions are non-necessary and non pythonic. You can, and should use the class constructor directly, like so :
ne = NonEmpty(1, 2)
You can also use an empty constructor and set the slots directly in your application, if what you need is some kind of record
class NonEmpty():
__slots__ = ('one', 'two')
n = NonEmpty()
n.one = 12
n.two = 15
You need to understand that slots are only necessary for performance/memory reasons. You don't need to use them, and probably shouldn't use them, except if you know that you are memory constrained. This only should be after actually stumbling into a problem though.