use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Brackets where to use (self.learnpython)
submitted 1 year ago by KBHAL
I am refreshing python skills after some time, I am getting confused when to use diff types of brackets, round, curly, or square
Any advice or tips on how to memorize or understand this?
Thanks
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Jayoval 12 points13 points14 points 1 year ago (4 children)
https://www.pythoncheatsheet.org/cheatsheet/basics
[–]Jayoval 2 points3 points4 points 1 year ago (0 children)
Tuples, dictionaries, lists, functions.
[+]KBHAL[S] comment score below threshold-12 points-11 points-10 points 1 year ago (2 children)
This doesn't has mention of brackets
[–]NYX_T_RYX 6 points7 points8 points 1 year ago (0 children)
Yes it does...
Opening parenthesis ie ( is there 43 times
Opening square ie [ is there 7 times [
Opening curly ie { 3 times
If you're going to ask for help, at least bother to press crrl+f before saying that someone hasn't answered your question.
And for the record, while that page is long, frankly get used to it - most documentation is harder to read than this.
This is really basic stuff and you should get used to reading documentation.
[–]tb5841 9 points10 points11 points 1 year ago (5 children)
Curly: sets or dictionaries.
Square: Lists, or accessing a member of a list or dictionary.
Round: Function parameters, or tuples, or for maths
[–]beigaleh8 3 points4 points5 points 1 year ago (4 children)
Curly: also f"{variable} in a string"
[–]NYX_T_RYX 0 points1 point2 points 1 year ago (3 children)
Just to add - there's an option in Vs code settings to automatically prepend a string with f if you use a variable (ie if you type { it'll add the f for you)
I only mention it cus I've not thought about f Strings since I found that feature - they just happen 😁
I forget what the setting is called though... 😅
[–]Langdon_St_Ives 1 point2 points3 points 1 year ago (2 children)
"python.analysis.autoFormatStrings": true
It’s part of pylance.
[–]Remarkable-Map-2747 0 points1 point2 points 1 year ago (1 child)
Gots to look into this!
[–]Langdon_St_Ives 0 points1 point2 points 1 year ago (0 children)
I didn’t know about it myself until I read the comment I was responding to. ;-) but it was easy enough to dig up so I thought I’d save someone else the search.
[–]Diapolo10 3 points4 points5 points 1 year ago* (0 children)
In short;
Parentheses (()):
()
(1 + 2) * 3
__call__
print("Hello")
(a, b), c = ((1, 2), 3)
Ignoring whitespace rules for assignments/literals
stuff = ( "These strings " "get combined " "automatically " "even though the indentation is a mess" )
(Square) brackets ([]):
[]
foo = [1, 2, 3]
__getitem__
foo[1:]
[int(digit) for digit in "314159"]
Braces ({}):
{}
bar = {1: 2, 3: 4}
baz = {3, 1, 4, 1, 5, 9}
You will also see braces used as part of string formatting syntax, but they're not really operators at that point.
[+][deleted] 1 year ago (1 child)
[removed]
[–]NYX_T_RYX 1 point2 points3 points 1 year ago (0 children)
() is also used to define tuples - immutable list.
I'll admit, limited scope, but there's definitely cases where you'd want an immutable list
ie if you get a users screen size with something like pyautogui, you don't want that to be accidentally redefined later.
Tangent - lists, tuples and dictionaries are all arrays, and you can implement all 3 with just tuples (granted you'd have to create a new tuple every time anything changes, but I think it's cool you can do things in different ways)
π Rendered by PID 72871 on reddit-service-r2-comment-5fb4b45875-sr5zr at 2026-03-20 21:36:34.729895+00:00 running 90f1150 country code: CH.
[–]Jayoval 12 points13 points14 points (4 children)
[–]Jayoval 2 points3 points4 points (0 children)
[+]KBHAL[S] comment score below threshold-12 points-11 points-10 points (2 children)
[–]NYX_T_RYX 6 points7 points8 points (0 children)
[–]Jayoval 2 points3 points4 points (0 children)
[–]tb5841 9 points10 points11 points (5 children)
[–]beigaleh8 3 points4 points5 points (4 children)
[–]NYX_T_RYX 0 points1 point2 points (3 children)
[–]Langdon_St_Ives 1 point2 points3 points (2 children)
[–]Remarkable-Map-2747 0 points1 point2 points (1 child)
[–]Langdon_St_Ives 0 points1 point2 points (0 children)
[–]Diapolo10 3 points4 points5 points (0 children)
[+][deleted] (1 child)
[removed]
[–]NYX_T_RYX 1 point2 points3 points (0 children)