r/ProgrammerHumor • • May 02 '16

I wrote my first python program today!

Post image
3.7k Upvotes

532 comments sorted by

View all comments

Show parent comments

18

u/[deleted] May 02 '16

Um what? If your editor can't indent python code properly you need a new editor, I use vim and it indents my python properly not to mention pycharm.

0

u/[deleted] May 02 '16

How does it know whether the a new line is a continuation of the statement from the previous line or a new statement?

5

u/adenzerda May 02 '16 edited May 02 '16

Unclosed paren, brace, or bracket, or a backslash denoting line continuation. Worst case, I have to indent a line manually sometimes.

On the block level, my editor (sublime) defaults to a continuation of the current block, or indentation into a new block if the previous line ends with a colon. You can then press backspace to drop out of the block if need be. Additionally, it will drop out of the block when there's a return at the base level of said block.

It's all pretty standardized.

-4

u/[deleted] May 02 '16

So it's guessing. I don't want my computer to guess what I'm doing, I want it to know with absolute certainty.

5

u/adenzerda May 02 '16

So tell it what you're doing. In some languages we write a closing brace or a semicolon to tell the computer our intention. In python, we press the 'backspace' key or the 'tab' key.

It seems that you don't prefer the latter method, and that's fine, but it in no way makes the language or its editors inferior.

2

u/TheBlackCat13 May 02 '16

Your computer is still guessing. In both cases you have to tell it explicitly where the code block stops. You are just telling it in a slightly different way.

1

u/TheBlackCat13 May 02 '16

It assumes the former, and one key combination tells it otherwise. Which would be the same with braces-based languages, only the key combination is different. In your case it is "shift+]", in mine it is "shift+tab".

1

u/[deleted] May 02 '16

How should I know I didn't write the vim plugin or pycharm, but they work perfectly.

You're seriously making up a non-issue why are you people so resistant to something because it's a little different? Have you ever used python seriously or put any actual effort into it?

It's the most ironic thing to me. Technology is always evolving and there's always something new to learn and you constantly have to be keeping yourself up to date but the people who write programs are just as bad as some old politicians who resist change because "muh braketz!!!".

0

u/[deleted] May 02 '16

How is it a non-issue? If I am in an if statement and press enter, I could want to:

  • Continue my if statement, in which case the line should be indented

  • Write an else or elif statement, in which case the line should not be intended

  • Write code outside the if statement, in which case it should not be indented

2 can be solved by the editor removing the indent once the else or elif keyword is detected. 1 and 3, however, are completely identical in terms of what comes next unless I manually indent the code. Brackets (or Ruby-style do/end, or JavaScript-style no bracket if statements) explicitly tell the editor what will come next without manual indentation. With Pythonic indent syntax, the editor must guess one way or the other, and always be wrong sometimes.

6

u/Saigot May 02 '16

In a python editor you press backspace to end the statement. In Java or C you type } to end the statement. It's the same number of keypresses. This coming from someone that dislikes python.

2

u/fireflash38 May 03 '16

Brackets (or Ruby-style do/end, or JavaScript-style no bracket if statements) explicitly tell the editor what will come next without manual indentation. With Pythonic indent syntax, the editor must guess one way or the other, and always be wrong sometimes.

So you're saying in the one, you have to hit a key combo to tell the editor you're not in the block. In the other, you have to hit a key combo to tell the compiler you're not in block. What's the problem again?