News for hackers. Stuff that matters.
Re:I don't like Python. Does that make me a bad person? by alphamerik on Saturday June 26, 2010 @08:20AM (#1463575)
I do indent my code, but I prefer to auto-indent. Using indentation to determine if a line of code falls inside or outside some logic block requires a lot more effort for me. Would much rather just use curly braces. Curly braces also make copying and pasting code blocks much easier.
Re:I don't like Python. Does that make me a bad person? by nailer on Saturday June 26, 2010 @08:34AM (#1463591)
I use auto indent on python all day. Not having to perform secondary bracket mark up is great.
Re:I don't like Python. Does that make me a bad person? by maw on Saturday June 26, 2010 @10:03AM (#1463679)
You don't, because auto indent for python doesn't and can't exist.
Re:I don't like Python. Does that make me a bad person? by crystalis on Saturday June 26, 2010 @10:42AM (#1463733)
You say this, and get points, but I'm not sure what you mean. I've written Python and gotten each new line to automatically indent to the proper point, with a functional backspace that unindents the appropriate amount. I've then copy-pasted blocks with several different indentation levels that were automatically adjusted to the surrounding code, with the possible exception of an error corrected by a single keypress.

To my knowledge, this is no worse than the expectation for a braced language, but much better than the worst case for a braced language.

If you mean something simpler than I've taken you to mean, e.g., the conversion of a whitespaceless C program into a whitespaced one, I concede you are mostly correct (';' still works in Python), but I must admit I would still not yet see your point.

Re:I don't like Python. Does that make me a bad person? by maw on Sunday June 27, 2010 @09:42AM (#1465468)
If you write code like this:

  if x:
      # do stuff
  # do other stuff
Your indenter will not know where to put the third line.

In languages whose blocks are closed using nonwhitespace the problem doesn't exist. Your indenter just has to push everything as far to the right as it can, and problem solved.

It's nice that your editor gets copy and paste right, but it doesn't and indeed can't decide how to indent your code, something that works in every other language I've dealt with.

Re:I don't like Python. Does that make me a bad person? by crystalis on Sunday June 27, 2010 @08:24PM (#1466608)
Why does that matter?

In brace language:

if (condition) {{ code_1 }} code_2

In Python:

if (condition):\n code_1 \n^H code_2

Unless your editor also knows when to place your close braces, and, haha, it doesn't and indeed can't, you have not even won a keystroke.

Re:I don't like Python. Does that make me a bad person? by maw on Tuesday June 29, 2010 @03:52PM (#1472546)
Once I've placed my closing braces, I'll never need to think about it again, unless and until I restructure that piece of code.

It's got nothing about saving keystrokes.

And now, back to working on pass-infested Python code.

Re:I don't like Python. Does that make me a bad person? by koenigdavidmj on Saturday June 26, 2010 @01:38PM (#1463969)
Vim does pretty well. On starts of blocks (when I hit : followed by return) I get an indent. At the usual places that would end a block (return, raising an exception, break or continue) I get a dedent automatically.
Re:I don't like Python. Does that make me a bad person? by gcr on Saturday June 26, 2010 @11:05AM (#1463757)
Are you sure? A counterexample: My editor indents every line that I end with a colon (:). So I just type : and <enter> and have a new indent. When I want to unindent, I just type backspace to go back one tab. This is simple to implement and understand, and with python, it's really all I need.

This kind of "automatic indentation" (colon-enter to indent, a quick backspace to unindent) feels much more natural to me than a C-style indent, where the editor's cue to indent would be space-rightbracket-enter and leftbracket-enter to unindent.

True, one cannot come accross a completely unindented block of python code and ask the editor to format it correctly for them. But by definition, unindented code is not valid python and will not run. This is not unlike C / C++ / Java code that's missing all its braces, which would not run either.

Re:I don't like Python. Does that make me a bad person? by jonknee on Saturday June 26, 2010 @10:43AM (#1463737)
I think he means in his editor. I do the same, it works well.
Re:I don't like Python. Does that make me a bad person? by T_S_ on Saturday June 26, 2010 @11:36AM (#1463793)
Whitespace doesn't help you write code. I helps you read code, which is a lot harder writing it, even though it seems like it should be the other way around.

The pain of keeping indentation correct is a forced ongoing investment in readability that is well worth it--at least to me.

I'm glad that haskell also has whitespace rules.