title: In python, how can I print lines that do NOT contain a certain string, rather than print lines which DO contain a certain string:
body: <p>I am trying to condense a very large log file, and to do so, I must eliminate every line which contains the string "StatusRequest" and "StatusResponse", while printing the other lines w/o this string. The code I have so far is as follows (to run from the command prompt):</p>
  
  <blockquote>
  <pre><code>   if (sys.argv[1])=="--help":
         print ("\n")
         print ("Argument 1: Enter name of '.py' file")
         print ("-i or --input: name of Catalina log")
         print ("-o or --output: file to output to")
         print ("\n")
     if (sys.argv[1])=="-h":
         print ("\n")
         print ("Argument 1: Enter name of '.py' file")
         print ("-i or --input: name of Catalina log")
         print ("-o or --output: file to output to")
         print ("\n")
  
     else:
         print 'Number of arguments:', len(sys.argv), 'arguments.'
         print 'Argument List:', str(sys.argv)
  
         Numarg = (len(sys.argv))
         i=1
         while i&lt;=(Numarg-4):
             search1="StatusRequest"
             search2="StatusResponse"
             if (sys.argv[Numarg-2])=="-o":
                 outputfile=sys.argv[Numarg-1]
  
             if (sys.argv[Numarg-2])=="--output":
                 outputfile=sys.argv[Numarg-1]
  
             if (sys.argv[i])=="-i":
                 filename=(sys.argv[i+1])
  
                 log=(filename)
                 print ("You entered the log: " + log)
  
                 f=open(log, 'r')
                 read_data = f.read()
                 f.close
  
                 f=open(log, 'r')
                 readlines_data=f.readlines()
                 f.close()
                 i=i+1
             if (sys.argv[i])=="--input":
                 filename=(sys.argv[i+1])
                 log=(filename)
                 print ("You entered the log: " + log)
  
                 f=open(log, 'r')
                 read_data = f.read()
                 f.close
  
                 f=open(log, 'r')
                 readlines_data=f.readlines()
                 f.close()
                 i=i+1
             for line in readlines_data:
                 if not ("StatusRequest" or "StatusResponse") in line:
                     result=line
                     print (line)
         f=open(outputfile, 'a')
         f.write(result + "\n")
         f.close()
  </code></pre>
  </blockquote>
  
  <p>You can just focus on the end of the script to answer my question, really...Anyways, I am not sure why this doesn't work...It is outputting every line still. And I already tried switching the place of the not so it would make more sense idiomatically, but it didn't change anything with the code. Any help is much appreciated :)</p>