From python 2.7 tutorial:
A pair of braces creates an empty
dictionary: {}. Placing a
comma-separated list of key:value
pairs within the braces adds initial
key:value pairs to the dictionary;
this is also the way dictionaries are
written on output.
tel = {'jack': 4098, 'sape': 4139}
data = {k:v for k,v in zip(xrange(10), xrange(10,20))}
While:
The dict() constructor builds
dictionaries directly from lists of
key-value pairs stored as tuples. When
the pairs form a pattern, list
comprehensions can compactly specify
the key-value list.
tel = dict([('sape', 4139), ('guido', 4127), ('jack', 4098)]) {'sape': 4139, 'jack': 4098, 'guido': 4127}
data = dict((k,v) for k,v in zip(xrange(10), xrange(10,20)))
When the keys are simple strings, it
is sometimes easier to specify pairs
using keyword arguments:
dict(sape=4139, guido=4127, jack=4098)
>>> {'sape': 4139, 'jack':4098, 'guido': 4127}
So both {} and dict() produce dictionary but provide a bit different ways of dictionary data initialization.