I have some code which tots up a set of selected values. I would like to define an empty set and add to it, but {} keeps turning into a dictionary. I have foun
As has been pointed out - the way to get an empy set literal is via set(), however, if you re-wrote your code, you don't need to worry about this, eg (and using set()):
from operator import itemgetter
query = ['four', 'two', 'three']
result = set().union(*itemgetter(*query)(inversIndex))
# set([0, 1, 2])