Just starting to figure Python out. I’ve read this question and its responses:
Is it true that I can't use curly braces in Python?
and I still can’t fathom how curly braces work, especially since pages like Simple Programs:
http://wiki.python.org/moin/SimplePrograms
use curly braces all over the place. I understand square brackets and regular curved parentheses, but I don’t know what’s meant by “defining dictionaries” or what they’re supposed to represent.
"Curly Braces" are used in Python to define a dictionary. A dictionary is a data structure that maps one value to another – kind of like how an English dictionary maps a word to its definition.
Python:
They are also used to format strings, instead of the old C style using %, like:
They are not used to denote code blocks as they are in many "C-like" languages.
C:
Update: In addition to Python’s
dictdata types Python has (since Python 2.7) set as well, which uses curly braces too and are declared as follows: