You don't need "math" brackets -- just use nested parentheses. Humans use [] in writing out complex math expressions to make them more readable to other humans, but this isn't necessary. They don't mean anything different than regular parentheses. So, when writing code, just stick to the parentheses.

Answer from PurpleVermont on Stack Overflow
Discussions

Different meanings of brackets in Python - Stack Overflow
What do the 3 different brackets mean in Python programming? [] - Normally used for dictionaries, list items () - Used to identify parameters {} - I don't know what this does Can these brackets c... More on stackoverflow.com
🌐 stackoverflow.com
Meaning of square brackets
HI I wonder if any one can help me understanding the use of the square brackets on the end of this statement. mail_ids = mails[0].decode().split()[-2:] How does the [-2:] work? thanks dazza000 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
Bython: Python with braces. Because Python is awesome, but whitespace is awful
I just wrote my code as normal (indented, thank you very much) and could ignore semicolons and curly braces, and the code just ran · I was done in half the time More on news.ycombinator.com
🌐 news.ycombinator.com
89
60
March 16, 2024
🌐
GeeksforGeeks
geeksforgeeks.org › python › parentheses-square-brackets-and-curly-braces-in-python
Parentheses, Square Brackets and Curly Braces in Python - GeeksforGeeks
July 26, 2025 - Curly braces define dictionaries and sets, both of which are mutable collections. Square brackets are crucial for defining lists and accessing elements through indexing and slicing. Mastery of these symbols allows Python developers to effectively manipulate data structures and perform various operations, enhancing their coding proficiency.
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.

🌐
Python.org
discuss.python.org › python help
Meaning of square brackets - Python Help - Discussions on Python.org
October 24, 2022 - HI I wonder if any one can help me understanding the use of the square brackets on the end of this statement. mail_ids = mails[0].decode().split()[-2:] How does the [-2:] work? thanks dazza000
Find elsewhere
🌐
Codecademy
codecademy.com › learn › cspath-cs-101 › modules › cspath-python-lists › cheatsheet
CS101: Introduction to Programming: Python: Lists Cheatsheet | Codecademy
In Python, lists are ordered collections of items that allow for easy use of a set of data. List values are placed in between square brackets [ ], separated by commas. It is good practice to put a space between the comma and the next value.
🌐
Processing
py.processing.org › reference › indexbrackets
[] (Index brackets) \ Language (API)
Python Mode for Processing extends the Processing Development Environment with the Python programming language.
🌐
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 …
🌐
Reuven Lerner
lerner.co.il › home › blog › python › python parentheses primer
Python parentheses primer — Reuven Lerner
November 10, 2022 - The square brackets tell Python that this is a list comprehension, producing a list.
🌐
Hacker News
news.ycombinator.com › item
Bython: Python with braces. Because Python is awesome, but whitespace is awful | Hacker News
March 16, 2024 - I just wrote my code as normal (indented, thank you very much) and could ignore semicolons and curly braces, and the code just ran · I was done in half the time
🌐
Quora
quora.com › What-is-the-difference-between-and-brackets-in-Python
What is the difference between {} and [] brackets in Python? - Quora
Originally Answered: What is the difference between using “()”, “[]” and “{}” in Python? · · [] is used for creation of empty list. They can be used for slicing operations in a list, tuple or array.
🌐
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 - Python’s Brackets, Parentheses, and Curly Braces Brackets — [], parentheses — (), & curly braces — {} are fundamental concepts that should be understood when dealing with the Python …
🌐
Sololearn
sololearn.com › en › Discuss › 2872013 › brackets-in-python
Brackets In Python | Sololearn: Learn to code for FREE!
Python has a very wide use for brackets from inputs to strings. It is all very confusing. How can I make sure that I am not mixing up wrong brackets in a practical pro
🌐
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(). ...
🌐
Python.org
discuss.python.org › python help
Tuple declaration using square brackets - Python Help - Discussions on Python.org
July 21, 2022 - I sometimes see this Tuple declaration which is not common: VARIABLE = Tuple[List[Tuple[str, float, Dict[str, Any]]], Dict[str, str]] VAR = Tuple[…] I was expecting Tuple with parentheses. Any help to understand? Tha…
🌐
Softonic
brackets.en.softonic.com › home › windows › development & it › web development
Brackets - Download
November 3, 2025 - Brackets is a solid editor which has everything you need when you work with files and directories as well as creating new files. Its code completion features let you quickly assemble apps without even knowing the exact syntax.
Rating: 8.4/10 ​ - ​ 1.94K votes
🌐
Python
peps.python.org › pep-0008
PEP 8 – Style Guide for Python Code | peps.python.org
Continuation lines should align wrapped elements either vertically using Python’s implicit line joining inside parentheses, brackets and braces, or using a hanging indent [1]. When using a hanging indent the following should be considered; there should be no arguments on the first line and ...
🌐
PyPI
pypi.org › project › brackets
brackets · PyPI
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser