I have the following code.
import os
products = [
{"Product": "S65-85OS04_M2M_GP211_JC222_R6",
"PlatformName": "winPc",
"PlatformVariant": "eeprom",
"DocGeneration": False,
"BuildStatus": "Pass",
},
{"Product": "SC5-01OS19_GP221_JC302_LTE_MTN",
"PlatformName": "winPc",
"PlatformVariant": "flash",
"DocGeneration": False,
"BuildStatus": "Fail",
},
{"Product": "SC5-01OS01_GP211_JC302_LTE_TMO",
"PlatformName": "winPc",
"PlatformVariant": "flash",
"DocGeneration": False,
"BuildStatus": "Pass",
}
]
class UTE(object):
def __init__(self, workspace, products, blackList=None):
for each in products:
# print each
if each['Product'] in blackList:
products.remove(each)
for each in products:
print each["Product"]
if __name__ == '__main__':
ins = UTE('ws', products, ["SC5-01OS01_GP211_JC302_LTE_TMO", "SC5-01OS19_GP221_JC302_LTE_MTN"])
Now whenever I run this, it removes only one entry in the dict. For example, in this case it is removing the 2nd entry and that is SC5-01OS19_GP221_JC302_LTE_MTN
. I believe this is something related to shallow copy..Am I right ?? If not then how solve this issue?