title: Python import a module into one class only
body: <p>I am trying to get a module to import, but only if an object of a specific class is called.  For example:</p>
  
  <pre><code>class One(object):
      try:
          import OneHelper
      except ImportError:
          pass
      def __init__(self):
          # this function doesn't use OneHelper
          ...
  
      def blah(self):
          # this function does
          OneHelper.blah()
  </code></pre>
  
  <p>This causes a <code>NameError: global name 'OneHelper' is not defined</code> when the <code>One.blah()</code> function is called. So far the only thing I have found that works is importing the module into the actual functions that use it. So:</p>
  
  <pre><code>class One(object):
      def __init__(self):
          # this function doesn't use OneHelper
          ...
  
      def blah(self):
          try:
              import OneHelper
          except ImportError:
              pass
          # this function does
          OneHelper.blah()
  </code></pre>
  
  <p>But I don't want to have to import the module in each function I want to use it in, I want it to be available to the whole class, but <em>only</em> if an instance of that class is instantiated.  Apologies if I'm not being clear enough...</p>