Yes it is a list comprehension with a condition. List comprehensions can have multiple conditions.
The general format for a list comprehension with a if
condition is this,
[<expression> for <value> in <iterable> if <condition>]
You can also have an if..else
in the comprehension
[<expression> if <condition> else <expression> for <value> in <iterable> ]
NOTE: Your iterable can be list,tuple,set,string,...etc
To make things clear consider this simple example,
>>> v = [1,2,3,4]
>>> v
[1, 2, 3, 4]
Assume this is your v
from your given code, also for understanding purposes let's say Wname
is something similar to W.name
>>> Wname = [1,2]
>>> Wname
[1, 2]
Now suddenly you decide I want a list x which has items from v but not in Wname. Hmmm... How to do that? Take a look below.
>>> x = [W for W in v if W not in Wname]
>>> x
[3, 4]
Somewhat along these lines is what's happening in the code you mentioned above.