title: Python checking if files exist before writing
body: <p>I have a file that contains .odt files and I would like to convert them to pdf. My current function works fine, the problem is that even if the file is already converted, the function converts it again, and I do not want to convert a file if it is already converted.</p>
  
  <p>Is there a way to check if the name.odt and name.pdf files already exist?</p>
  
  <pre><code>import sys
  import os
  import comtypes.client
  import glob
  
  def convert():
      for file in glob.glob("*.odt"): # Listing all files
          wdFormatPDF = 17
          in_file = os.path.abspath(file)
          name, ext = os.path.splitext(file)
          suffix = '.pdf'
          os.path.join(name + suffix)
          if not os.path.exists(name): # Pdf file doesn't exist 
              out_file = os.path.abspath(name)
  
              word = comtypes.client.CreateObject('Word.Application')
              doc = word.Documents.Open(in_file)
              doc.SaveAs(out_file, FileFormat=wdFormatPDF)
              print('the file ' + name +' has been converted')
          else :
              print('all the file are converted')
  
      doc.Close()
      word.Quit()
  </code></pre>