Python and Ruby

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Mon Feb 1 07:27:29 CET 2010


On Sun, 31 Jan 2010 21:30:15 -0600, John Bokma wrote:

>>>>> While braces might be considered redundant they are not when for one
>>>>> reason or another formatting is lost or done incorrectly.
>>>>
>>>> I've heard this argument before, and I don't buy it. Why should we
>>>> expect the editor to correct malformed code?
>>> 
>>> Or a prettyfier. It doesn't matter. The point is that with braces
>>> there *is* redundancy that be used to fix the code.
>>
>> Prettyfiers are significant in languages that allow braces (or
>> begin/end tokens) and indentation to go out of sync. Since that can't
>> happen with Python,
> 
> Yes it can. I *have* seen Python with broken indentation on web pages,
> and good luck sorting it out. Blaming it on "broken tools" is just
> another straw man. 

You're using that term wrong. It looks to me that you don't actually know 
what a straw man argument is. A straw man argument is when somebody 
responds to a deliberately weakened or invalid argument as if it had been 
made by their opponent. You raised the issue that the redundancy which 
prettyfiers exploit are a good reason for preferring braces, so it's not 
a straw man argument.

It's not a straw man to say that you don't need a code prettyfier if 
indentation is significant when you raised the issue of prettyfiers in 
the first place.

I certainly accept that braces + indentation do provide redundancy, and 
if the norm was noisy channels, that redundancy would be valuable. But 
that's not the norm. Most channels don't delete leading whitespace, and 
those noisy channels we do deal with (like web forms) tend to introduce 
far more noise than merely deleting leading whitespace, e.g. word-
wrapping long lines.

The argument that "web pages break indentation, therefore braces are 
better" is a real argument that some people make, but it is very weak. 
Suppose there was a web page that arbitrarily deleted braces out of some 
misplaced sense of security. Would anyone argue that this proves that 
indentation was better and braces were bad? No, of course not -- they 
would say "That website is broken".




> It happens, and if you're learning Python and
> interested in that code you have a problem.

Yes you do.

If you're trying to learn carpentry, and somebody gives you a blunt saw 
that causes the wood to break rather than cut cleanly, you have a 
problem. If you're learning to cook, and they give you a put with a hole 
in it and tell you to make soup in it, you have a problem.

Broken tools lead to problems.


> Snipped the rest, because you start to sound like a zealot. I should've
> know better.

Yeah, whatever.



-- 
Steven



More information about the Python-list mailing list