title: Best way to execute instruction and set variables before any method call in Python class
body: <p>I need to set a number of environment variables and class properties before any other command is executed like for example:</p>
  <pre><code>def __init__(self):
    os.environ[&quot;HOST&quot;] = os.uname()[1]
    self._home = os.environ[&quot;HOME&quot;]
    self._storage = f'{self._home}/my-storage'
    self._service_names = None
    self._requirements_file = None
  </code></pre>
  <p>I also need to read some files and set some more variables.</p>
  <p>I thought to include them in the &quot;<strong>init</strong>&quot; function but I am thinking that this might make the class initialization step too slow.</p>
  <p>Is this recommended doing file reads and other potentially time consuming operations in <strong>init</strong>? What other mechanism does Python offer to ensure that as set of instruction is executed before a class method is executed? I could put these operations in a decorator function maybe?</p>