I have code that looks like this:
def _check(self) -> None:
cars = self.cars.all()
cars.sort(key=self.key)
names: Set[str] = set()
Can someone explain to me what the code names: Set[str] = set()
is doing?
I have code that looks like this:
def _check(self) -> None:
cars = self.cars.all()
cars.sort(key=self.key)
names: Set[str] = set()
Can someone explain to me what the code names: Set[str] = set()
is doing?
This is an initialisation with a type hint. It declares that the type of the variable names
is a set type with string values, which is initialised to an empty set (= set()
).