title: Access Class Variables in Python Package
body: <p>I am working through a python package that uses several functions under a single class and would like to access one of the classes function variables . How if possible can I do this? </p>
  
  <p>I've broken down the class and functions into single bits of code, but given the package is there a way for me to call the class hidden or otherwise? </p>
  
  <pre><code>    'def fit_scores(self, balance=True, nmodels=None):
      """
      Fits logistic regression model(s) used for
      generating propensity scores
      Parameters
      ----------
      balance : bool
          Should balanced datasets be used?
          (n_control == n_test)
      nmodels : int
          How many models should be fit?
          Score becomes the average of the &lt;nmodels&gt; models if nmodels &gt; 1
      Returns
      -------
      None
      """
      # reset models if refitting
      if len(self.models) &gt; 0:
          self.models = []
      if len(self.model_accuracy) &gt; 0:
          self.model_accuracy = []
      if not self.formula:
          # use all columns in the model
          self.formula = '{} ~ {}'.format(self.yvar, '+'.join(self.xvars))
      if balance:
          if nmodels is None:
              # fit multiple models based on imbalance severity (rounded up to nearest tenth)
              minor, major = [self.data[self.data[self.yvar] == i] for i in (self.minority, self.majority)]
              nmodels = int(np.ceil((len(major) / len(minor)) / 10) * 10)
          self.nmodels = nmodels
          i = 0
          errors = 0
          while i &lt; nmodels and errors &lt; 5:
              uf.progress(i+1, nmodels,
                          prestr="Fitting Models on Balanced Samples")
  
              # sample from majority to create balance dataset
              df = self.balanced_sample()
              df = pd.concat([uf.drop_static_cols(df[df[self.yvar] == 1], yvar=self.yvar),
                              uf.drop_static_cols(df[df[self.yvar] == 0], yvar=self.yvar)])
              y_samp, X_samp = patsy.dmatrices(self.formula, data=df, return_type='dataframe')
              X_samp.drop(self.yvar, axis=1, errors='ignore', inplace=True)
  
              glm = GLM(y_samp, X_samp, family=sm.families.Binomial())
              try:
                  res = glm.fit()
                  self.model_accuracy.append(self._scores_to_accuracy(res, X_samp, y_samp))
                  self.models.append(res)
                  i += 1
              except Exception as e:
                  errors += 1 # to avoid infinite loop for misspecified matrix
                  print('Error: {}'.format(e))
  
          print("\nAverage Accuracy:", "{}%".
                format(round(np.mean(self.model_accuracy) * 100, 2)))
      else:
          # ignore any imbalance and fit one model
          print('Fitting 1 (Unbalanced) Model...')
          glm = GLM(self.y, self.X, family=sm.families.Binomial())
          res = glm.fit()
          self.model_accuracy.append(self._scores_to_accuracy(res, self.X, self.y))
          self.models.append(res)
          print("\nAccuracy", round(np.mean(self.model_accuracy[0]) * 100, 2))'
  </code></pre>
  
  <p>I would like to be able to call 
  <code>res</code> So that I can access <code>print(res.summary)</code> or any other section of the statsmodel package.</p>