title: Python __Slots__ (Making and Using)
body: <p>I don't really get making a class and using <code>__slots__</code> can someone make it clearer? </p>
  
  <p>For example, I'm trying to make two classes, one is empty the other isn't. I got this so far:</p>
  
  <pre><code>class Empty:
      __slots__ =()
  
  def mkEmpty():
      return Empty()
  
  class NonEmpty():
      __slots__ = ('one', 'two')
  </code></pre>
  
  <p>But I don't know how I would make "mkNonEmpty". I'm also unsure about my mkEmpty function.</p>
  
  <p>Thanks</p>
  
  <p>Edit:</p>
  
  <p>This is what I ended up with:</p>
  
  <pre><code>class Empty:
      __slots__ =()
  
  def mkEmpty():
      return Empty()
  
  class NonEmpty():
      __slots__ = ('one', 'two')
  
  def mkNonEmpty(one,two):
      p = NonEmpty()
      p.one= one
      p.two= two
      return p
  </code></pre>