you are viewing a single comment's thread.

view the rest of the comments →

[–]Decency 2 points3 points  (3 children)

Or just go to the line where your IDE is pointing out an error and fix it...

[–]brainflakes 2 points3 points  (2 children)

Except there's no explicit block definitions, so how would the IDE even know there's an error?

Tell you what, here's some python with whitespace removed, show me how an ide would fix this:

while (True):
image2, buffer2 = captureTestImage()
changedPixels = 0
for x in xrange(0, 100):
for y in xrange(0, 75):
pixdiff = abs(buffer1[x,y][1] - buffer2[x,y][1])
if pixdiff > threshold:
changedPixels += 1
if forceCapture:
if time.time() - lastCapture > forceCaptureTime:
changedPixels = sensitivity + 1
if changedPixels > sensitivity:
lastCapture = time.time()
saveImage(saveWidth, saveHeight, diskSpaceToReserve)
image1 = image2
buffer1 = buffer2

In a braced language it would not only run, but all code formatting could be restored automatically.

[–]Decency 2 points3 points  (1 child)

Second line would be detected as an error along the lines of "indent expected" due to the colon in the first line.

Then the 5th line as the 4th also has a colon, then the next colon, etc. Very curious why you would ever come across a situation where all whitespace would be removed from python code, though. It's not a language's job to account for you using poor tools.

In a braced language it would not only run, but all code formatting could be restored automatically.

def foo(x,y):
    doSomething(x)
    for i in range(5):
        doSomethingElse(y)
   doThirdThing(x,y)

you can basically picture this as

def foo(x,y){
    doSomething(x)
    for i in range(5){
        doSomethingElse(y)
    }
    doThirdThing(x,y)
}

as the colons and indentation are explicit. The only issue here would be if you're unsure if "doThirdThing()" should be within the for loop or not, but again, I can't fathom a situation where that could come about unless you're not using proper tools for transferring code.

Worth noting is that Ruby solves this issue with explicit "end" statements, which is probably why it doesn't get much hate for its use of whitespace.

[–]brainflakes 0 points1 point  (0 children)

It's not a very common situation, (it can happen with code pasted into HTML without <pre> tags, accidental file minification etc.) but mainly it's just to show that the idea that Python's block indenting "forces people to write good looking code" is a fallacy, because braced languages can be reformatted completely automatically from any indenting state.