Linked by Eugenia Loli on Sat 15th Jul 2006 22:45 UTC
.NET (dotGNU too) Jeff Cogswell writes: "I'm about to make a confession. Even though I've written several books and articles about C++, I have a secret: C++ isn't my favorite language. I have lots of languages that I use, each one for different purposes. But the language I consider my all-time favorite is Python."
Thread beginning with comment 143651
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[4]: Python is . . .
by CrLf on Sun 16th Jul 2006 22:31 UTC in reply to "RE[3]: Python is . . ."
CrLf
Member since:
2006-01-03

"There are programming idioms, such as manual loop unrolling, which are clearer when multiple statements are allowed on a line."

And Python allows multiple statements on a single line, using a ";". And code blocks can also have just one line. The following code...

for i in xrange(10): print i; print i*2

...is perfectly valid.

"Also, the tab replacement rule pretty much negates any advantage that using alignment to indicate block nesting gives you because you can't tell when reading the code how the indentation is going to work after tab replacement."

If you have aligned code, and you replace blocks of "n" spaces by tabs, you will end up with consistent results within a single code block.

As I said, people who complain about the indentation "problem" haven't actually used the language.

Reply Parent Score: 1

RE[5]: Python is . . .
by Cloudy on Mon 17th Jul 2006 01:26 in reply to "RE[4]: Python is . . ."
Cloudy Member since:
2006-02-15

If you have aligned code, and you replace blocks of "n" spaces by tabs, you will end up with consistent results within a single code block.

Yes. But if you aren't doing the replacement consistently, you can end up with code that looks properly indented when displayed, but that the compiler treats as having different indentation than you think you see.

I'd try to show you an example, but since OSNews' display software eats tabs and spaces, you can't actually show valid Python code with it.

As I said, people who complain about the indentation "problem" haven't actually used the language.

I've used it. I miessed that ';' was allowed as a statement separator, and withdraw the comments about it, but I still hold the comments about indentation level not being unambiguously determinable (which wikipedia agrees with.)

Reply Parent Score: 1

RE[6]: Python is . . .
by CrLf on Mon 17th Jul 2006 14:01 in reply to "RE[5]: Python is . . ."
CrLf Member since:
2006-01-03

"Yes. But if you aren't doing the replacement consistently, you can end up with code that looks properly indented when displayed, but that the compiler treats as having different indentation than you think you see."

And why should I do that? There is only one reason that calls for "spaces->tabs" or "tabs->spaces" replacement: when one or the other is enforced in a particular project, and you want to add code that used the "wrong" indentation method.

Problems may come up when replacing inside aligned lines that continue statements (like splitting a "print" over multiple lines), and code may look aligned when it isn't. But Python doesn't care about indentation in split statements, so there is no problem there.

I also complained about indentation when I first started with Python, but soon realized that it is a non-issue. People can come up with multiple scenarios where problems could arise, but in practice they never do. I'm still waiting to hear about a real-world situation where indentation in python caused problems.

And to those stating that not using indentation is sometimes desirable... I don't want to look at your code... ever!

Reply Parent Score: 1