title: Python class member lazy initialization
body: <p>I would like to know what is the python way of initializing a class member but only when accessing it, if accessed.
  I tried the code below and it is working but is there something simpler than that?</p>
  
  <pre><code>class MyClass(object):
  
      _MY_DATA = None
  
      @staticmethod
      def _retrieve_my_data():
          my_data = ...  # costly database call
          return my_data
  
      @classmethod
      def get_my_data(cls):
          if cls._MY_DATA is None:
              cls._MY_DATA = MyClass._retrieve_my_data()
          return cls._MY_DATA
  </code></pre>