def _backupFile(filePath):
 assert os.path.exists(filePath)
 stampNum = 0
 (prefix, suffix) = os.path.splitext(filePath)
 while True:
  backupPath = ('%s.%d%s' % (prefix, stampNum, suffix))
  stampNum += 1
  if (not os.path.exists(backupPath)):
   break
 shutil.copyfile(filePath, backupPath)
 return backupPath

def _backupFile ( filePath ) : assert os . path . exists ( filePath ) stampNum = 0 ( prefix , suffix ) = os . path . splitext ( filePath ) while True : backupPath = ( '%s.%d%s' % ( prefix , stampNum , suffix ) ) stampNum += 1 if ( not os . path . exists ( backupPath ) ) : break shutil . copyfile ( filePath , backupPath ) return backupPath
back up a file parameters: retval: filepath of the back-up .