title: how to perform AND operation on ip address and subnet mask in python
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/819355/how-can-i-check-if-an-ip-is-in-a-network-in-python">How can I check if an ip is in a network in python</a>  </p>
  </blockquote>
  
  
  
  <p>I have one destination ip address from a file suppose <code>ip1 = 172.16.0.34</code>; and I have one more file having (subnet, mask, next-hop) i.e <code>172.16.0.0</code>, <code>255.255.255.0</code>, <code>117.120.10.1</code></p>
  
  <p>I have to check whether the incoming address ip1 matches the subnet entry for a particular route,after being ANDed with the netmask of that entry in the routing table. If the destination matches under mask,add the route to the list of feasible routes for this packet  </p>