I have scoured the internet and I cannot find any reference to this type of for
loop:
variable = [(item["attribute1"], item["attribute2]") for item in piece_of_json_data]
I am using this to update wtform's SelecField choices:
form.SelectField.choices = variable
but I can only get it to work if I replace one of the attributes in parenthesis with a static number:
variable = [(1, item["attribute2"]) for item in piece_of_json_data]
but that sets the value of the option field to "1"
, when I need the option values to be one of the attributes as a string.
Does this create a dict? a tuple? is there some kind of terminology for this that I can use to find documentation?