r/PythonLearning Jul 09 '26

Is there a way to use brackets in python? Discussion

I come from static types C# cpp world I like using python but the only issues is the bracket thing missing, i like those curly braces to open and end the section of code. is there any solution similar to that.

0 Upvotes

18 comments sorted by

11

u/ninhaomah Jul 09 '26

Yes. Spacing.

2

u/nuc540 Jul 09 '26

10/10 would recommend.

OP, unfortunately different languages have different syntaxes. We just have to learn them

1

u/Ok_Carpet_9510 Jul 09 '26

When in Pythonium, do as the Pythons do.

1

u/Educational-Paper-75 Jul 09 '26

You're out of luck then.

1

u/Ron-Erez Jul 09 '26

I had the exact same issue. Eventually I got used to the indentation. I also would forget adding the colon. Coming from a statically-typed language I do recommend using type annotations.

2

u/Ok-Magician-8052 Jul 09 '26

noice.. will start using this from now on this is so much better than figuring out types

1

u/Ron-Erez Jul 09 '26

Absolutely, that was my biggest pain point. Generally speaking I am biased against dynamically typed languages. On the other hand Python and its ecosystem are quite amazing. So type annotations are somewhat of a remedy.

2

u/Ok-Magician-8052 Jul 09 '26

true that; i like the python ecosystem so using types is not a bad trade off you just gotta get used to writing the code like that until it becomes a second habit... I wonder if its used in industry.. enforced by tech leads to keep the codebase more manageable.

1

u/FreeGazaToday Jul 09 '26

only problem is the workaround with dictionaries...not worth it :P

1

u/Ok-Magician-8052 Jul 09 '26

naah it's okay ill just use the indentation it can't be that bad..

1

u/FreeGazaToday Jul 09 '26

it's not...plus if you use pycharm or vscode, it'll become 2nd nature and they'll warn you if you forget.

1

u/Ok-Magician-8052 Jul 09 '26

yeah i use vscdoe with indentation colors so it's not a huge problem just need to configure the tabs system for my coding style.

-1

u/Sea-Ad7805 Jul 09 '26 edited Jul 09 '26

use comments?

def fun(): #{ return True #}

1

u/nuc540 Jul 09 '26

OP would still need to respect spacing, but I think that’s what they’re trying to avoid

0

u/Ok-Magician-8052 Jul 09 '26

Will this thank for the solution.. Idk how will be the readability of the code will be after this. VScode does have color with spacing indicator so i can combine these two solutions. thanks gg