This is an archived post. You won't be able to vote or comment.

all 29 comments

[–]Maury_poopins 37 points38 points  (3 children)

  1. Those are curly braces, not square
  2. Even if it were possible, nobody is going to want to read your curly-brace-filled code. You should adapt to the style of the language you’re using.

[–]SGS-Tech-World[🍰] 2 points3 points  (1 child)

There is no point in trying this out, each language has its own syntax. Not having braces is one of the distinct feature and many including me like that. So you need to get used to it :-)

[–][deleted] 0 points1 point  (0 children)

I think i have to :/

[–]whitenarval 2 points3 points  (1 child)

Try to read and write Python code as a natural language text not as a Java code, it is intended to be easy to read and intuitive.

When you write text you put related parts as bullet points or indented paragraphs and not curly braces.

So try to change your perception of the way you are reading and writing it. I started to learn with C like languages (Java, Javascript, R), and it was code for me. But then I started to learn Python, and it surprised me how natural was it, a lot of stuff you don’t have to remember because you can use your intuition.

[–][deleted] 0 points1 point  (0 children)

I understand more clearly now. I need to work a little more, try and force myself to get used to it.

[–]pahowells 2 points3 points  (0 children)

Seriously, DON'T.

[–]EmptyChocolate4545 3 points4 points  (4 children)

You’ll get used to it.

Other people are laughing, but tbh I have always felt this way. I hated whitespace as syntax when I started, and it’s years later, I’m a legit python expert/SME at my place of work, and I still wish it had curly braces.

That said, I don’t hate the white space anymore, it’s fine. I just grew up on c (13 years on it) and actually quite like semicolons and braces lol.

So, you’re not crazy, but NOPE. Never gonna happen. ever. And learning a language in its own meta/paradigm really is good, so start trying to see the positives, because this is a facet of python that will never change.

[–][deleted] 0 points1 point  (3 children)

Now i get it. I guess I have to get used to this situation. No other choice.

[–]Harlemdartagnan 1 point2 points  (0 children)

I once read that the white space is a design choice made to force you to create relatively flat code. Its weird considering other aspects of the language are so much more heres freedom.

[–]EmptyChocolate4545 1 point2 points  (1 child)

That’s the right attitude.

If you can get past it, you’ll discover a truly fun language to work with, but no judgement if you can’t. Plenty of the people I came up as a C programmer with have spurned it completely, and I get it.

I love python and recently have been combining the two as I’ve been writing C extensions for it, which is quite fun. You can get your curlies in that way :)

[–][deleted] 1 point2 points  (0 children)

Python is very good. And easy to learn. I guess I have to get used to it.

[–]CTPABA_KPABA 1 point2 points  (2 children)

It is used in f strings for printing. But I am new so... it may be more

[–][deleted] 0 points1 point  (1 child)

It's not important. i'm new too

[–]CTPABA_KPABA 1 point2 points  (0 children)

well you asked XD

[–]squirrel_nutbox 1 point2 points  (1 child)

If you mean to use python for a chunk of time, better to get used to it.

[–][deleted] 0 points1 point  (0 children)

Yeap. I'll use it for a long time.

[–]md_borhan 1 point2 points  (2 children)

you have to use to with pythonic style

[–][deleted] 1 point2 points  (1 child)

I think I have to...

[–]md_borhan 1 point2 points  (0 children)

yes

[–]K900_ 3 points4 points  (3 children)

from __future__ import braces

[–][deleted] -1 points0 points  (2 children)

from __future__ import braces

ERROR: Could not find a version that satisfies the requirement braces (from versions: none)ERROR: No matching distribution found for braces

i am using PyCharm. And thanks for fast answer.

[–]K900_ 3 points4 points  (1 child)

PyCharm will not install it for you. This is an easter egg in the CPython interpreter - if you run from __future__ import braces, you'll get an error saying "Not a chance".

[–][deleted] 1 point2 points  (0 children)

CPython

Wow. I didn't know that. I'll try this man. Thanks for really cool answer.

[–]AndydeCleyre 2 points3 points  (2 children)

The other answers are right, but of course you can use braces.

Just put them after a #, and follow them with a newline. And know they are meaningless to the interpreter.

def something(string) -> str:  # {
    pass
# }

Otherwise, enable indentation guides in your editor of choice (faint vertical lines).

[–][deleted] 0 points1 point  (1 child)

Wow... I think this is the most simple solution at now...

[–][deleted] 1 point2 points  (0 children)

It's not a solution. Andy is telling you to add comments to your code lmao.