title: Using a classmethod to retrieve or load data on init
body: <p>I have a time-consuming database lookup (downloads data from online) which I want to avoid doing constantly, so I would like to pickle the data if I don't already have it. </p>
  
  <p>This data is being used by the class which has this classmethod.</p>
  
  <p>Is this a 'proper' or expected use of a classmethod? I feel like I could fairly easily refactor it to be an instance method but it feels like it should be a classmethod due to what it's doing. Below is a mockup of the relevant parts of the class.</p>
  
  <pre class="lang-py prettyprint-override"><code>import os
  import pickle
  
  class Example:
      def __init__(self):
          self.records = self.get_records()
  
      @classmethod
      def get_records(cls):
          """
          If the records aren't already downloaded from the server, 
          get them and add to a pickle file. 
          Otherwise, just load the pickle file.
          """
          if not os.path.exists('records.pkl'):
              # Slow request
              records = get_from_server()
  
              with open('records.pkl', 'wb') as rec_file:
                  pickle.dump(records, rec_file)
          else:
              with open('records.pkl', 'rb') as rec_file:
                  records = pickle.load(rec_file)
  
          return records
  
      def use_records(self):
          for item in self.records:
              ...
  </code></pre>
  
  <p>Is there also an easy way to refactor this so that I can retrieve the data on request, even if the pickle file exists? Is that as simple as just adding another argument to the classmethod?</p>
  
  <p>Thanks for any help.</p>