Jul-30-2022, 09:06 PM
You guessed wrong. In "protein: Nutrient = Nutrient(name="Protein")" the colon is used in a type hint, not in a dictionary.
protein is a variable. It is assigned the value Nutrient(name="Protein"). The assignment has a type hint telling the reader that Nutrient(name="Protein") returns an instance of class "Nutrient".
variable : type_hint = value
protien : Nutrient = Nutrient(name="Protein")
The code does exactly the same thing if you leave the type hint out.
protien = Nutrient(name="Protein")
protein is a variable. It is assigned the value Nutrient(name="Protein"). The assignment has a type hint telling the reader that Nutrient(name="Protein") returns an instance of class "Nutrient".
variable : type_hint = value
protien : Nutrient = Nutrient(name="Protein")
The code does exactly the same thing if you leave the type hint out.
protien = Nutrient(name="Protein")