title: Getting TypeError: unsupported operand type(s) for |=: 'str' and 'bool' message when trying to run script
body: <p>I have a python script where I'm trying to determine if .txt files in json format return positive or negative for containing certain statements. Some of the example statements are: <strong>"elevated exposure", "phishing and other frauds", "suspicious content"</strong>. After determining if each .txt file returns positive or negative, the script is supposed to write the result to a csv. There are about 100,000 .txt files I'm trying to process. I'm getting a <code>TypeError on line 22</code> of my code though. The full error message is: </p>
  
  <pre><code>TypeError: unsupported operand type(s) for |=: 'str' and 'bool' message when trying to run script 
  </code></pre>
  
  <p>I have included my code and sample .txt file in json format below.</p>
  
  <p><strong>sample JSON format file</strong></p>
  
  <pre><code>{
      "detected_referrer_samples": [
          {
              "positives": 1,
              "sha256": "325f928105efb4c227be1a83fb3d0634ec5903bdfce2c3580ad113fc0f15373c",
              "total": 52
          },
          {
              "positives": 20,
              "sha256": "48d85943ea9cdd1e480d73556e94d8438c1b2a8a30238dff2c52dd7f5c047435",
              "total": 53
          }
      ],
      "detected_urls": [],
      "domain_siblings": [],
      "resolutions": [],
      "response_code": 1,
      "verbose_msg": "Domain found in dataset",
      "whois": null
  }
  </code></pre>
  
  <p><strong>Full Traceback</strong></p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/virustotal_reporter.py", line 47, in &lt;module&gt;
      vt_result_check(path)
    File "C:/virustotal_reporter.py", line 22, in vt_result_check
      vt_result |= any(sample['positives'] &gt; 0 for sample_type in sample_types
  TypeError: unsupported operand type(s) for |=: 'str' and 'bool'
  </code></pre>
  
  <p><strong>Code</strong></p>
  
  <pre><code>import os
  import json
  import csv
  
  path="C:/Users/bwerner/Documents/output/"
  
  
  def vt_result_check(path):
      vt_result = False
      for filename in os.listdir(path):
          with open(path + filename, 'r') as vt_result_file:
              vt_data = json.load(vt_result_file)
  
          l = ()
  
          # Look for any positive detected referrer samples
          # Look for any positive detected communicating samples
          # Look for any positive detected downloaded samples
          # Look for any positive detected URLs
          sample_types = ('detected_referrer_samples', 'detected_communicating_samples',
                          'detected_downloaded_samples', 'detected_urls')
          vt_result |= any(sample['positives'] &gt; 0 for sample_type in sample_types
                                                   for sample in vt_data.get(sample_type, []))
  
          # Look for a Dr. Web category of known infection source
          vt_result |= vt_data.get('Dr.Web category') == "known infection source"
  
          # Look for a Forecepoint ThreatSeeker category of elevated exposure
          # Look for a Forecepoint ThreatSeeker category of phishing and other frauds
          # Look for a Forecepoint ThreatSeeker category of suspicious content
          threats = ("elevated exposure", "phishing and other frauds", "suspicious content")
          vt_result |= vt_data.get('Forcepoint ThreatSeeker category') in threats
  
          vt_result = str(vt_result)
          print(vt_result)
  #        with open('output.csv', 'w') as outfile:
  #            outfile.write(vt_result)
  #        print(vt_result_check(path))
  
          #f.writerow(vt_result_check(path))
  
  #        l.append(vt_result)
  
      return vt_result
  
  if __name__ == '__main__':
      vt_result_check(path)
  #    for i in range(vt_result_check(path)):
  </code></pre>