title: How to diff a range of IP addresses within a range in Python 2.x?
body: <p>Given an IP range, how can code to subtract an IP address or IP address range from that range?</p>
  
  <p>Example 1:</p>
  
  <pre><code>original_range = '10.182.110.0/24'
  # Same as '10.182.110.0-10.182.110.255'
  subtract_range = '10.182.110.51-10.182.254'
  &gt; diff_range = '10.182.110.0-10.182.110.50, 10.182.110.255'
  </code></pre>
  
  <p>Example 2:</p>
  
  <pre><code>original_range = '10.10.20.0-10.10.20.20'
  subtract_range = '10.10.20.16'
  &gt; diff_range = '10.10.20.10-10.10.20.15, 10.10.20.17-10.10.20.20'
  </code></pre>
  
  <p>Example 3:</p>
  
  <pre><code>original_range = '10.170.0.0/16'
  # Same as '10.170.0.0-10.170.31.255'
  subtract_range = '10.170.20.16'
  &gt; diff_range = '10.170.0.0-10.170.20.15, 10.170.20.17-10.170.31.255'
  </code></pre>