title: Python How to make a cross-module function?
body: <p>I want to be able to call a global function from an imported class, for example</p>
  
  <p>In file PetStore.py</p>
  
  <pre><code>class AnimalSound(object):
     def __init__(self):
        if 'makenoise' in globals():
           self.makenoise = globals()['makenoise']
        else:
           self.makenoise = lambda: 'meow'
  
     def __str__(self):
        return self.makenoise()
  </code></pre>
  
  <p>Then when I test in the Python Interpreter</p>
  
  <pre><code>&gt;&gt;&gt; def makenoise():
  ...    return 'bark'
  ...
  &gt;&gt;&gt; from PetStore import AnimalSound
  &gt;&gt;&gt; sound = AnimalSound()
  &gt;&gt;&gt; sound.makenoise()
  'meow'
  </code></pre>
  
  <p>I get a 'meow' instead of 'bark'. I have tried using the solutions provided in <a href="https://stackoverflow.com/questions/142545/python-how-to-make-a-cross-module-variable">python-how-to-make-a-cross-module-variable</a> with no luck.</p>