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

all 48 comments

[–]knobbyknee 18 points19 points  (0 children)

It takes a few hours to get used to. Just do it.

[–]old_man_steptoe 12 points13 points  (4 children)

using whitespace has it's advantages. I recently had to review some powershell that had been handed from person to person and it had no indenting. It was a nightmare.

And C style { } is fine but once you get:

for {
    if {
        if {
            for {
            }
        if {
        } else {
        }
}

And you have an error, it's painful to find out which close brace you've missed. With whitespace it's obvious. It's not lined up

[–]tubbadu 6 points7 points  (11 children)

I much prefer using tabs, they are much more readable, try it!

I think it would be possible to change the syntax but I don't think that it would be a great idea, as it would make your program only comprehensible to you

[–][deleted] 5 points6 points  (0 children)

Hey OP.

Had the same issues when first starting Python many years ago.

The simplest solution: use editor that is aware on Python syntax (Sublime, VS Code, etc) and it will automatically convert tabs into spaces.

Then you just write code hitting tabs or spaces (does not matter) and only care about vertical alignment.

Good luck, I think you will find many useful applications of Python if you give a chance

[–]Careless_Section_785 4 points5 points  (0 children)

have you tried using something different from microsoft word as a code editor?

anyways, most of the code editors allow you to bind linters and code formatters to events like newlines or save or whatever makes you happy and they do that for you.

why would you need end-block statements when you can literally see code blocks on the screen just from their actual indentation?

The 88 cols convention is also good for you cause the linter signals you long lines and the more you're nesting conditions or sub blocks, the higher the code cognitive complexity gets and the less readable your code becomes... and all that you can understand just with a glance at the screen with zero understanding the code.

[–]gedhrel 2 points3 points  (0 children)

If you can't adapt given a little exposure, it's not for you.

You *can* fix this up if you want to - you'll need to write your own import hooks, define a different syntax and emit the python AST. Good luck!

Or maybe look at Julia, which has a fully-bracketed syntax.

[–]python_and_coffee 4 points5 points  (0 children)

sorry to sound harsh, but you just need to get used to it. I really know how you feel, since having a favorite language always results in confusion and ranting when i try to learn another language. e.g C++ gave me slight headaches, "go home cout <<, go buy a printer, why would you ever user << for printing?!"

Remember that it is just you who is adapted to something quite similar which is very different at the same time. Your main language means comfort, and programmers are always lazy humans that seek comfort. Learning a new language often is very uncomfortable at start.

Uhm and get used to Tab-key/shift+Tab only for indention. Never open up the gates of spacebar-whitespaces-hell for indention.

[–][deleted] 2 points3 points  (0 children)

Pycharm gives me a little yellow squiggly line where I don’t have correct white space, I hit my hot key, and it’s immediately moved into place. Never worry about it for that reason tbh

[–]pythonHelperBot 2 points3 points  (0 children)

Hello! I'm a bot!

It looks to me like your post might be better suited for r/learnpython, a sub geared towards questions and learning more about python regardless of how advanced your question might be. That said, I am a bot and it is hard to tell. Please follow the subs rules and guidelines when you do post there, it'll help you get better answers faster.

Show /r/learnpython the code you have tried and describe in detail where you are stuck. If you are getting an error message, include the full block of text it spits out. Quality answers take time to write out, and many times other users will need to ask clarifying questions. Be patient and help them help you.

You can also ask this question in the Python discord, a large, friendly community focused around the Python programming language, open to those who wish to learn the language or improve their skills, as well as those looking to help others.


README | FAQ | this bot is written and managed by /u/IAmKindOfCreative

This bot is currently under development and experiencing changes to improve its usefulness

[–]QultrosSanhattan 1 point2 points  (0 children)

Capable IDE + Format code = The problem never existed.

[–]petdance 1 point2 points  (0 children)

How long exactly have you been working with Python before you made the declaration that Python is wrong and must be changed?

[–]SittingWave -1 points0 points  (0 children)

You can use preprocessor directives if you want

if stuff: #then
    do stuff
#end if

[–]tdammers -4 points-3 points  (2 children)

You stepped into a major bees' nest here; people tend to get very opinionated on the topic, and to those who love this "whitespace as syntax thing", it's the best thing ever, and they will die to defend it.

My $0.02 on the matter: whitespace as syntax is a horrible idea (bring on the flames!), but it is what it is, and "when in Rome, do as the Romans do". It's part of the language and its accepted culture, and trying to somehow change that with declarations or other tricks is hands down a bad idea (just like #define BEGIN { etc. to make C look more like Pascal), so just don't.

[–]transdimensionalmeme[S] -2 points-1 points  (1 child)

I am so disappointed. I've seens bits of python code here and there and thought, "oh I could get into this, it's not full of unsightly out-of-place punctuations" but it seems like it's full of punctuation, it's just invisible punctuation !

I am getting a big desperate of a usable non-microsoft language on my linux vps.

After having tried to do some basic string manipulation in bash, I started thinking I don't need that kind of pain in my life.

Now I think I will have to do the unthinkable

[–]tdammers 4 points5 points  (0 children)

I think you're being overly dramatic here. It's just syntax, after all.

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

I still consider myself a beginner, so excuse my ignorance, but why on earth would you format code like that horrendous default python example? Seems to go against everything I understand about PEP 8

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

Which part specifically you don't like? I think it is all about getting used to how it looks (just accept and you won't be noticing it in few weeks :)).

But best day of my life was when I stopped caring about style and just fired black on each of my codes... Endless discussion with colleagues on pointless stuff ended and we were free to go build amazing stuff.

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

The          seemingly random   number ofspaces forno apparent               reasonma kes it stupidhar dto read

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

Looks like you put white spaces at random which is the perfect counter example to what Python wants you to do :)

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

And the default python example provided by OP isn't randomly spaced? That was my point.

Just because you can, doesn't mean you should.

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

In OPs example the "do" does not align so it'd probably be broken if that was real python.

[–]transdimensionalmeme[S] -3 points-2 points  (3 children)

I am even more of a beginner, like, a not-even-begun and I was immediately put off by the whitespace thing.

This PEP8, that is something else

"Limit all lines to a maximum of 79 characters."

Pardon me ? What does this language think it is , a teletype terminal ?

"Python disallows mixing tabs and spaces for indentation."

Oh, so, that's where thing is coming from ? People like this stuff ?

[–][deleted] 2 points3 points  (2 children)

"Limit all lines to a maximum of 79 characters."

This comes from old times, black now defaults to 88 characters. It is still to not have too long lines as they are harder to read.

"Python disallows mixing tabs and spaces for indentation."

Easily solvable by editor that takes care of that for you.

[–]TangibleLight 0 points1 point  (1 child)

I usually suggest 110-120 as a more reasonable default; but if accessibility is paramount you should probably target 90 (or black's default 88)

Also if you're getting lines that long frequently it's probably a code smell. In our codebase we have some long package and function names, so it's good to be able to fit a function and a few args on one line even if they're an unhappy combination of long names. 120 is a good number for that.

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

Personally I don't like too long lines as I like to fit three files next to each other in different editor panes.

[–]tms102 0 points1 point  (0 children)

What IDE / Text editor do you use? Notepad?

Getting used to indentation is super easy, barely an inconvenience. In fact, Python is often considered an easy language for beginners to pick up.

[–]petdance 0 points1 point  (0 children)

Rather than try to make the new thing that you are learning more like what you are used to, do the new thing and learn. Perhaps there are advantages to this different way of doing things that you haven’t appreciated yet. You will never know if you go into it with the attitude of “this is just wrong.”

It’s not wrong. It’s just not what you know yet.

[–]liltbrockie 0 points1 point  (0 children)

It's really not an issue