I've a doubt about lambda expression with internal list comprehension operation.
In the following code, the lambda will instantiate a list for each item every time?
def _find_items_not_present_in_store(self, store_today, store_yesterday):
# finding what items are not in the store anymore
items_not_in_store_anymore = filter(lambda item1: item1.item_id not in
[item2.item_id for item2 in store_today.store_items],
store_yesterday)
return items_not_in_store_anymore
Would be better have this list
[item2.item_id for item2 in store.store_items]
instantiated outside of the lambda expression?
I couldn't find any documentation about it.