Subtract two lists of tuples from each other
<p>I have the these two lists and I need to subtract one from the other but the regular "-" won't work, neither will .intersection or XOR (^). </p>

<pre><code>A = [(0, 1)]
B = [(0, 0), (0,1), (0, 2)]
</code></pre>

<p>Essentially what I want is:</p>

<pre><code>B - A = [(0, 0), (0, 2)]
</code></pre>

<p>You can use list comprehension to solve this problem: </p>

<pre><code>[item for item in B if item not in A]
</code></pre>

<p>More discussion can be found <a href="http://stackoverflow.com/questions/3428536/python-list-subtraction-operation">here</a></p>

python list tuples subtraction