by stillinbeta · 13y ago · 0 comments
myset = {x for x in "This is my stuff".split()}
mydict = {x:len(x) for x in "This is my stuff".split()}
The advantage of this syntax is that : unambiguously introduces a key: value pair, whereas (key, value) could also occur in a list comprehension (e.g., by accident).