What is the meaning of curly braces?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Mysterious Puzzle
--
Chapters
00:00 What Is The Meaning Of Curly Braces?
00:27 Answer 1 Score 6
01:02 Accepted Answer Score 111
01:48 Answer 3 Score 0
02:14 Answer 4 Score 10
02:33 Thank you
--
Full question
https://stackoverflow.com/questions/9197...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #curlybraces #parentheses #braces
#avk47
ACCEPTED ANSWER
Score 111
"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:
dict = {
    "a" : "Apple",
    "b" : "Banana",
}
They are also used to format strings, instead of the old C style using %, like:
ds = ['a', 'b', 'c', 'd']
x = ['has_{} 1'.format(d) for d in ds]
print x
['has_a 1', 'has_b 1', 'has_c 1', 'has_d 1']
They are not used to denote code blocks as they are in many "C-like" languages.
C:
if (condition) {
    // do this
}
Update: In addition to Python's dict data types Python has (since Python 2.7) set as well, which uses curly braces too and are declared as follows:
my_set = {1, 2, 3, 4}
ANSWER 2
Score 10
In languages like C curly braces ({}) are used to create program blocks used in flow control.  In Python, curly braces are used to define a data structure called a dictionary (a key/value mapping), while white space indentation is used to define program blocks.
ANSWER 3
Score 6
Dictionaries in Python are data structures that store key-value pairs. You can use them like associative arrays. Curly braces are used when declaring dictionaries:
d = {'One': 1, 'Two' : 2, 'Three' : 3 }
print d['Two'] # prints "2"
Curly braces are not used to denote control levels in Python. Instead, Python uses indentation for this purpose.
I think you really need some good resources for learning Python in general. See https://stackoverflow.com/q/175001/10077
ANSWER 4
Score 0
A dictionary is something like an array that's accessed by keys (e.g. strings,...) rather than just plain sequential numbers. It contains key/value pairs, you can look up values using a key like using a phone book: key=name, number=value.
For defining such a dictionary, you use this syntax using curly braces, see also: http://wiki.python.org/moin/SimplePrograms