title: Writing to a pcap with scapy
body: <p>I'm trying to write to a pcap file once I filter out all NBNS traffic. This is giving me a syntax error.</p>
  
  <pre><code>from scapy.all import *
  
  Capture = raw_input("Enter file path of pcap file: " )
  pcap = rdpcap(Capture)
  
  ports=137
  
  filtered = (pkt for pkt in Capture if
      (UDP in pkt and 
      (pkt[UDP].sport in str(ports)))
  
  wrpcap("filtered.pcap",filtered)
  </code></pre>
  
  <hr>
  
  <p>I found the answer for the syntax error was just a missing parenthesis at the end of <code>...str(ports))))</code> but now I have a different error. </p>
  
  <pre><code>  File "receiver2.py", line 18, in &lt;module&gt;
      wrpcap("filtered.pcap",filtered)
    File "/usr/lib/python2.7/dist-packages/scapy/utils.py", 
      line 470, in wrpcap
    PcapWriter(filename, *args, **kargs).write(pkt)
    File "/usr/lib/python2.7/dist-packages/scapy/utils.py", line 652, in write
      for p in pkt:
    File "receiver2.py", line 13, in &lt;genexpr&gt;
      (UDP in pkt and 
    TypeError: 'in &lt;string&gt;' requires string as left operand, not Packet_metaclass
  </code></pre>