title: Passing a relative path in a function
body: <p>Can someone tell me if the following function declaration is the correct way to pass a relative path to a function? The call is only taking one variable. When I include a second variable (absolute path), my function does not work.</p>
  
  <pre><code> def extract(tar_url, extract_path='.'):
  </code></pre>
  
  <p>The call that does not work:</p>
  
  <pre><code> extract(chosen, path)
  </code></pre>
  
  <p>This works, but does not extract:</p>
  
  <pre><code> extract(chosen)
  </code></pre>
  
  <p>Full Code:</p>
  
  <pre><code> def do_fileExtract(self, line):
     defaultFolder = "Extracted"
     if not defaultFolder.endswith(':') and not os.path.exists('c:\\Extracted'):
         os.mkdir('c:\\Extracted')
         raw_input("PLACE .tgz FILES in c:\Extracted AT THIS TIME!!! PRESS ENTER WHEN FINISHED!")
     else:
         pass
  
     def extract(tar_url, extract_path='.'):
         print tar_url
         tar = tarfile.open(tar_url, 'r')
         for item in tar:
            tar.extract(item, extract_path)
            if item.name.find(".tgz") != -1 or item.name.find(".tar") != -1:
               extract(item.name, "./" + item.name[:item.name.rfind('/')])
  
  
     userpath = "Extracted"
     directory = os.path.join("c:\\", userpath)
     os.chdir(directory)
     path=os.getcwd() #Set log path here
     dirlist=os.listdir(path)
  
  
     files = [fname for fname in os.listdir(path) 
                    if fname.endswith(('.tgz','.tar'))]
  
     for item in enumerate(files):
         print "%d- %s" % item
  
     try:
         idx = int(raw_input("\nEnter the file's number:\n"))
     except ValueError:
         print "You fail at typing numbers."
  
     try:
         chosen = files[idx]
     except IndexError:
         print "Try a number in range next time."
  
  
     newDir = raw_input('\nEnter a name to create a folder a the c: root directory:\n')
     selectDir = os.path.join("c:\\", newDir)
     path=os.path.abspath(selectDir)
  
     if not newDir.endswith(':') and not os.path.exists(selectDir):
        os.mkdir(selectDir)
  
  
     try:
  
         extract(chosen, path)
         print 'Done'
     except:
         name = os.path.basename(sys.argv[0])
         print chosen
  </code></pre>