title: Initialize properties when called or in __init__ in Python
body: <p>Is it better style to define private class variables in the __init__ method or in the getter? It seems like there is no need to define the variable until it is called.</p>
  
  <p>Defining the variable in <strong>init</strong>:</p>
  
  <pre><code>class Foo(object):
      def __init__(self):
          self._bar = None
  
      @property
      def bar(self):
          if self._bar is None:
              self._bar = Bar()
          return self._bar
  
      @bar.setter
      def bar(self, value):
          self._bar = value
  </code></pre>
  
  <p>Defining it in the getter:</p>
  
  <pre><code>class Foo(object):
      @property
      def bar(self):
          if not hasattr(self, '_bar'):
              self._bar = Bar()
          return self._bar
  
      @bar.setter
      def bar(self, value):
          self._bar = value
  </code></pre>