I thought what I had was a common problem, but I could not find any help either in Google nor in SO.
I have 2 lists that contain objects of class Marker. A Marker consists of variables name, position and type. I want to intersect the two lists, create tuples of markers of the same type and store them in a new list. Literally speaking, I want to do something like the following:
g_markerList = [ (marker1,marker2) for marker1 in marker1List and marker2 in marker2List if marker1.type == marker2.type ]
Apparently, this code does not work. Compiler does not ''know'' variable marker2 following and, which ends the for clause.
Please help me to intersect these two lists and obtain a list of tuples of similar markers!
Change the and to for:
g_markerList = [ (marker1,marker2) for marker1 in marker1List
                                   for marker2 in marker2List
                                   if marker1.type == marker2.type ]
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With