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
A set literal is just a tuple of values in curly braces:
x = {2, 3, 5, 7}
So, you can create an empty set with empty tuple of values in curly braces:
x = {*()}
Still, just because you can, doesn't mean you should.
Unless it's an obfuscated programming, or a codegolf where every character matters, I'd suggest an explicit x = set()
instead.
"Explicit is better than implicit."