I am trying to understand lambda Python code. How to translate this in normal Python?
self.myarray = [j for j in line if j.type not in (obj.key1, obj.key2)]
I am trying to understand lambda Python code. How to translate this in normal Python?
self.myarray = [j for j in line if j.type not in (obj.key1, obj.key2)]
That syntax represents a list comprehension and it does the same thing as below code:
self.myarray = []
for j in line:
if j.type not in (obj.key1, obj.key2):
self.myarray.append(j)