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.

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
Quick Test: What are the 4 types of Brackets in Python called?

Parentheses, bigger/lesser , square brackets, curly brackets ๐Ÿ˜€

More on reddit.com
๐ŸŒ r/PythonLearning
2
1
June 14, 2023
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
July 28, 2020
Brackets where to use
https://www.pythoncheatsheet.org/cheatsheet/basics More on reddit.com
๐ŸŒ r/learnpython
14
5
May 26, 2024
๐ŸŒ
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.
๐ŸŒ
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 ...
๐ŸŒ
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.
๐ŸŒ
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 ...
๐ŸŒ
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 `{}`.
๐ŸŒ
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].
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
Kodeclik
kodeclik.com โ€บ brackets-in-python
Brackets in Python: Parentheses, Square Brackets and Curly Braces
March 21, 2025 - 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.
๐ŸŒ
YouTube
youtube.com โ€บ edlitera
How to Use Curly Braces in Python - YouTube
Welcome back to the third part in our Python Parentheses Tutorial! We continue with curly braces in Python, which are used to create dictionaries, dictionary...
Published ย  April 15, 2023
Views ย  3K
๐ŸŒ
CodeRivers
coderivers.org โ€บ blog โ€บ python-brackets
Mastering Python Brackets: A Comprehensive Guide - CodeRivers
April 2, 2025 - 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.
๐ŸŒ
Open Book Project
openbookproject.net โ€บ books โ€บ bpp4awd โ€บ ch03.html
3. Strings, lists and tuples โ€” Beginning Python Programming for Aspiring Web Developers
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 )).
๐ŸŒ
Quora
quora.com โ€บ What-is-the-difference-between-and-brackets-in-Python
What is the difference between {} and [] brackets in Python? - Quora
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.