title: Python "while" loop with an "if" statement
body: <p>I'm having some troubles with an "if" statement at the begining of my "while" loop. My goal is to check if some three files are already downloaded to the workstation. If so, script is beginning next task. Otherwise, script is waiting 300 seconds and tries again to download files as long as needed to success. So far I have something like code posted below, which seemed to be working fine but results finally were wrong.</p>
  
  <pre><code>if not os.path.exists(somefile_1) or not os.path.exists(somefile_2) or not os.path.exists(somefile_3):
          readyToSend = 0
          while (readyToSend == 0):
              if not os.path.exists(somefile_1) or not os.path.exists(somefile_2) or not os.path.exists(somefile_3):
                  print 'There are some files missing. Restarting script.'
                  lgr.info('There are some files missing. Restarting script.')
                  start=300
                  while start &gt; 0:
                      time.sleep(1)
                      print 'Script will restart automatically in: ', start, '\r',
                      start -=1
                  removePIDfile()
                  execfile(r'D:\Workspace\tools\PKG_Maker\PKG_Maker.py')
              elif os.path.exists(somefile_1) and os.path.exists(somefile_2) and os.path.exists(somefile_3):
                  readyToSend = 1
                  print 'Restarting script not necessary. Files downloaded.'
  </code></pre>
  
  <p>I am pretty sure that using the same "if" statement twice is kind of useless, but without this, loop was starting the timer (tiny loop inside) without even checking if those files exist.</p>
  
  <p>This part of code above is not working as intended. I found out that even when I can see the files on workstation, I'm getting output that some files are missing. Messed up with these "if" and "while" statements and right now (due to my low experience) I just can't figure it out... </p>
  
  <p>I'm willing to learn so maybe someone is able to show me how should this be done or which part of it is ruining this.</p>