title: Python: Calling local function when an imported module has a function with same name
body: <p>I have imported a file <code>common.py</code> into the <code>copyPasteAnywhereTest.py</code> file. <code>common.py</code> has some common functions defined in it that I need to call in the current file viz. <code>copyPasteAnywhereTest.py</code>. But there is one particular function <code>copyText()</code> that I have defined in both the files. By default, <code>copyText()</code> from <code>common.py</code> is being called. I want to call the function that I have defined locally and not the one that I defined in the imported file. The code is something like below:</p>
  
  <p>This is one file <code>common.py</code></p>
  
  <pre><code>#common.py
  
  def copyText():
      #Function definition
  
  #Some more functions defined in this file.
  </code></pre>
  
  <p>This is the script file <code>copyPasteAnywhereTest.py</code></p>
  
  <pre><code>#copyPasteAnywhereTest.py
  
  import os
  import sys
  
  sys.path.append(os.path.abspath("../z_common/"))
  
  import common
  
  def main():
      #some code
      copyText()    #Calling the copyText() function
  
  def copyText():
      #Code here.
  </code></pre>
  
  <p><code>copyText()</code> from <code>common.py</code> was called whether I imported using <code>import common</code> or <code>from common import functionName</code></p>
  
  <p>The simplest solution was to change the name of <code>copyText()</code> in <code>copyPasteAnywhereTest.py</code> and call the same. But I want to know the proper solution and not a workaround.</p>
  
  <p>Just to be clear, I had't even imported the <code>copyText()</code> function in <code>copyPasteAnywhereTest.py</code> (i.e., <code>from common import copyText</code>) earlier while using the <code>from module import function</code> syntax. I have just imported the required functions using <code>from common import *functionName*</code>.</p>
  
  <p>P.S. - I am quite new to Python. Don't mind if the question is a stupid one. I've tried googling and searching over the internet but I couldn't find an answer. Hence, the question.</p>