I’m using the following list comprehension:
resources = [obj.get("file") for obj in iterator if obj.get("file") != None]
Is there a way to “cache” the value of obj.get("file") when it’s checked in the if statement so that it doesn’t have to call get again on obj when it generates the return list?
If you want to stay with list / iterator comprehensions instead of using
filteryou can simply use: