This is a dictionary comprehension. It has the following syntax:
{ k: v for item in sequence }
This will create a dictionary entry for every item
in sequence
with the key k
and the value v
.
For example, the following will create a dictionary with the keys from the sequence (1, 2, 3)
, and the squared number as the value:
>>> { x: x**2 for x in (1, 2, 3) }
{1: 1, 2: 4, 3: 9}
In your case, you have the following dictionary comprehension:
{ item: set() for item in extra_items_in_deps }
This will create a dictionary with the keys from extra_items_in_deps
and create a new set for each key. So assuming extra_items_in_deps = [1, 2, 3]
, itβs equivalent to this dictionary:
{ 1: set(), 2: set(), 3: set() }
This dictionary is then passed to data.update()
which updates the dictionary data
with the key-value pairs from the passed dictionary.