Square brackets: []

Lists and indexing/lookup/slicing

  • Lists: [], [1, 2, 3], [i**2 for i in range(5)]
  • Indexing: 'abc'[0]'a'
  • Lookup: {0: 10}[0]10
  • Slicing: 'abc'[:2]'ab'

Parentheses: () (AKA "round brackets")

Tuples, order of operations, generator expressions, function calls and other syntax.

  • Tuples: (), (1, 2, 3)
    • Although tuples can be created without parentheses: t = 1, 2(1, 2)
  • Order of operations: (n-1)**2
  • Generator expressions: (i**2 for i in range(5))
  • Function or method calls: print(), int(), range(5), '1 2'.split(' ')
    • with a generator expression: sum(i**2 for i in range(5))

Curly braces: {}

Dictionaries and sets, as well as in string formatting

  • Dicts: {}, {0: 10}, {i: i**2 for i in range(5)}
  • Sets: {0}, {i**2 for i in range(5)}
    • Except the empty set: set()
  • In string formatting to indicate replacement fields:
    • F-strings: f'{foobar}'
    • Format strings: '{}'.format(foobar)

Regular expressions

All of these brackets are also used in regex. Basically, [] are used for character classes, () for grouping, and {} for repetition. For details, see The Regular Expressions FAQ.

Angle brackets: <>

Used when representing certain objects like functions, classes, and class instances if the class doesn't override __repr__(), for example:

>>> print
<built-in function print>
>>> zip
<class 'zip'>
>>> zip()
<zip object at 0x7f95df5a7340>

(Note that these aren't proper Unicode angle brackets, like ⟨⟩, but repurposed less-than and greater-than signs.)

Answer from Maltysen on Stack Overflow
Top answer
1 of 4
82

Square brackets: []

Lists and indexing/lookup/slicing

  • Lists: [], [1, 2, 3], [i**2 for i in range(5)]
  • Indexing: 'abc'[0]'a'
  • Lookup: {0: 10}[0]10
  • Slicing: 'abc'[:2]'ab'

Parentheses: () (AKA "round brackets")

Tuples, order of operations, generator expressions, function calls and other syntax.

  • Tuples: (), (1, 2, 3)
    • Although tuples can be created without parentheses: t = 1, 2(1, 2)
  • Order of operations: (n-1)**2
  • Generator expressions: (i**2 for i in range(5))
  • Function or method calls: print(), int(), range(5), '1 2'.split(' ')
    • with a generator expression: sum(i**2 for i in range(5))

Curly braces: {}

Dictionaries and sets, as well as in string formatting

  • Dicts: {}, {0: 10}, {i: i**2 for i in range(5)}
  • Sets: {0}, {i**2 for i in range(5)}
    • Except the empty set: set()
  • In string formatting to indicate replacement fields:
    • F-strings: f'{foobar}'
    • Format strings: '{}'.format(foobar)

Regular expressions

All of these brackets are also used in regex. Basically, [] are used for character classes, () for grouping, and {} for repetition. For details, see The Regular Expressions FAQ.

Angle brackets: <>

Used when representing certain objects like functions, classes, and class instances if the class doesn't override __repr__(), for example:

>>> print
<built-in function print>
>>> zip
<class 'zip'>
>>> zip()
<zip object at 0x7f95df5a7340>

(Note that these aren't proper Unicode angle brackets, like ⟨⟩, but repurposed less-than and greater-than signs.)

2 of 4
5

In addition to Maltysen's answer and for future readers: you can define the () and [] operators in a class, by defining the methods:

  • __call__(self[, args...]) for ()
  • __getitem__(self, key) for []

An example is numpy.mgrid[...]. In this way you can define it on your custom-made objects for any purpose you like.

🌐
Data Science Discovery
discovery.cs.illinois.edu › guides › Python-Fundamentals › brackets
Parentheses, Square Brackets and Curly Braces in Python - Data Science Discovery
March 22, 2024 - Square brackets can be used to select out certain rows. ... 1.Creating Dictionaries Curly Braces {} are often used in dictionary creation. A dictionary in Python is an unordered collection of key-value pairs. Each key must be unique, and it is associated with a specific value.
Discussions

Meaning of square brackets
Ok, I think I have got it now. it is about the indexing of a list. I think it is referring to the last two elements of the list called mails · The first thing to understand is that the output from split() is a list. See the documentation for str.split(). A list is a sequence type · The second ... More on discuss.python.org
🌐 discuss.python.org
0
0
October 24, 2022
Add curly brackets to python please
**Please add curly brackets to the python language just like Java. If not that at least have editors like python highlight the indeting of classes and methods and put class or method label within the highlighting so the developer knows where they are. ** More on discuss.python.org
🌐 discuss.python.org
0
4
July 14, 2024
In python, when to use a square or round brackets? - Stack Overflow
They are part of the Python syntax and unlike using single (') or double (") quotes, they can pretty much never be interchanged. Square and rounded brackets can mean so many different things in different circumstances. Just to give an example, one may think that both the following are identical: ... as a[0] gives 1 in both cases. However, the first one is creating a list whereas the second is a tuple. These are different data types ... More on stackoverflow.com
🌐 stackoverflow.com
June 16, 2020
How to type bracket in python? Just hear me out okay?
I would solve this with your OS, not with python or IDLE. I'm a big fan of the compose key, aka .XCompose on Linux, or WinCompose on Windows. Or of course pick up a keyboard for literally a few dollars at your local thrift store. More on reddit.com
🌐 r/learnpython
11
7
June 16, 2020
🌐
Edlitera
edlitera.com › blog › posts › python-parentheses
Python Parentheses Cheat Sheet | Edlitera
In this article, I've demonstrated some of the different uses for standard parentheses, square brackets, and curly braces in Python that you can use as a cheat sheet.
🌐
Processing
py.processing.org › reference › indexbrackets
[] (Index brackets) \ Language (API)
Python Mode for Processing extends the Processing Development Environment with the Python programming language.
🌐
GeeksforGeeks
geeksforgeeks.org › python › parentheses-square-brackets-and-curly-braces-in-python
Parentheses, Square Brackets and Curly Braces in Python - GeeksforGeeks
July 26, 2025 - In conclusion, understanding the differences between parentheses (), curly braces {}, and square brackets [] in Python is essential for writing clear, efficient, and well-structured code.
🌐
Reuven Lerner
lerner.co.il › home › blog › python › python parentheses primer
Python parentheses primer — Reuven Lerner
November 10, 2022 - The fact that square brackets are so generalized in this way means that Python can take advantage of them, even on user-created objects.
Find elsewhere
🌐
Python.org
discuss.python.org › python help
Meaning of square brackets - Python Help - Discussions on Python.org
October 24, 2022 - Ok, I think I have got it now. it is about the indexing of a list. I think it is referring to the last two elements of the list called mails · The first thing to understand is that the output from split() is a list. See the documentation for str.split(). A list is a sequence type · The second ...
🌐
Plain English
python.plainenglish.io › pythons-brackets-parentheses-and-curly-braces-60cdc236cdd6
Python’s Brackets, Parentheses, and Curly Braces | by Emmanuel Adebanjo | Python in Plain English
August 22, 2023 - Curly braces denote a Dictionary in the Python programming language. A dictionary is an unordered data structure of key-value pairs. Note: A dictionary is a key-value pair. The keys must be unique and of homogenous(same) data type, while the ...
🌐
Reintech
reintech.io › blog › understanding-python-and-the-brackets-problem
Python and the Brackets Problem | Reintech media
October 4, 2023 - They can denote a list, a dictionary, an array, or a tuple, and they're also used in function and method invocations. There are three types of brackets - parentheses `()`, square brackets `[]`, and curly brackets `{}`.
🌐
Quora
quora.com › What-are-the-different-meanings-of-brackets-in-Python-programming
What are the different meanings of brackets in Python programming? - Quora
Round Brackets: * used to represent tuples like (1, 2, 4). * used to group expressions like in (a + b) * c + (x**p)**q - (f - g) #without brackets the expression will have different semantic.
🌐
Codecademy
codecademy.com › learn › cspath-cs-101 › modules › cspath-python-lists › cheatsheet
CS101: Introduction to Programming: Python: Lists Cheatsheet | Codecademy
In Python, list index begins at zero and ends at the length of the list minus one. For example, in this list, 'Andy' is found at index 2. ... Python list elements are ordered by index, a number referring to their placement in the list. List indices start at 0 and increment by one. To access a list element by index, square bracket notation is used: list[index].
🌐
Kodeclik
kodeclik.com › brackets-in-python
Brackets in Python: Parentheses, Square Brackets and Curly Braces
August 23, 2024 - In Python, there are three types of brackets—parentheses (), square brackets [], and curly braces {}. They serve distinct purposes, each essential for different aspects of programming.
🌐
Afeld
python-public-policy.afeld.me › en › columbia › brackets.html
Brackets in Python and pandas — Python for Public Policy @ Columbia University
In Python, parentheses are used in function definitions to specify the arguments. ... Then, parentheses are used to call functions, passing in the arguments (if any). ... When making a new instance of a class, you use parentheses after the class name. We saw this above with pd.DataFrame(). ... Angle brackets are used to do comparison.
🌐
CodeRivers
coderivers.org › blog › python-brackets
Mastering Python Brackets: A Comprehensive Guide - CodeRivers
March 15, 2010 - This blog post will dive deep into the world of Python brackets, exploring their fundamental concepts, usage methods, common practices, and best practices. ... Python has three main types of brackets: parentheses (), square brackets [], and curly braces {}. Each type has its own distinct purpose ...
🌐
SheCodes
shecodes.io › athena › 2453-how-to-use-square-bracket-syntax-in-python
[Python] - How to Use Square Bracket Syntax in Python - | SheCodes
Learn what square bracket syntax is and how to use it to access elements of an array or dictionary in Python.
🌐
Python.org
discuss.python.org › python help
Add curly brackets to python please - Python Help - Discussions on Python.org
July 14, 2024 - **Please add curly brackets to the python language just like Java. If not that at least have editors like python highlight the indeting of classes and methods and put class or method label within the highlighting so the …
🌐
Quora
quora.com › What-is-the-difference-between-and-brackets-in-Python
What is the difference between {} and [] brackets in Python? - Quora
March 21, 2025 - Curly braces {} and square brackets [] are syntactically and semantically different in Python. Below is a compact reference showing when each is used, how they behave, and common pitfalls.
🌐
Open Book Project
openbookproject.net › books › bpp4awd › ch03.html
3. Strings, lists and tuples — Beginning Python Programming for Aspiring Web Developers
July 15, 2019 - There is also the empty string, containing no characters at all. In the case of lists or tuples, they are made up of elements, which are values of any Python datatype, including other lists and tuples. Lists are enclosed in square brackets ([ and ]) and tuples in parentheses (( and )).
Top answer
1 of 3
14

They are part of the Python syntax and unlike using single (') or double (") quotes, they can pretty much never be interchanged.

Square and rounded brackets can mean so many different things in different circumstances. Just to give an example, one may think that both the following are identical:

a = [1,2,3]
a = (1,2,3)

as a[0] gives 1 in both cases. However, the first one is creating a list whereas the second is a tuple. These are different data types and not knowing the distinction can lead to difficulties.

Above is just one example where square and rounded brackets differ but there are many, many others. For example, in an expression such as:

4 * ((12 + 6) / 9)

using square brackets would lead to a syntax error as Python would think you were trying to create a nested list:

4 * [[12 + 6] / 9]

So hopefully you can see from above, that the two types of brackets do completely different things in situations which seem identical. There is no real rule of thumb for when one type does what. In general, I guess that square brackets are used mainly for lists and indexing things whereas rounded brackets are for calculations (as you would in maths) and functions etc.

Hope this helps you out a bit!

2 of 3
7

It's hard to answer succinctly, but I can give you some common examples.

Square brackets define lists:

my_list = [1, 2, 3, 4]

They are also used for indexing lists. For instance:

print(my_list[1])

Returns 2. Additionally, they are frequently used to index dictionaries, which are defined with curly brackets:

my_dict = {5:'a', 6:'b', 7:'c'}

The indexing for dictionaries requires that I input the "key" as follows:

print(my_dict[6])

Returns b.

Functions are called using round brackets. For instance, if I want to add an element to my list, I can call the append() function:

my_list.append(8)

I have just added 8 to my list. You will notice that when I called the print function I also used curved brackets.

This is by no means comprehensive, but hopefully it will give a starting point.