Compare source code

Steven D'Aprano steve-REMOVE-THIS at cybersource.com.au
Wed Nov 3 23:30:12 CET 2010


On Wed, 03 Nov 2010 20:35:20 +0000, Seebs wrote:

>>> This level of dogmatism about what should always be the case is not
>>> conducive to good software engineering practices.
> 
>> I question that assertion. Good engineering practices is about setting
>> best practices, and following them, not avoiding them because there
>> might be the odd exception here and there.
> 
> I don't think I buy this.  I've seen a whole lot of good writers and
> good programmers, and in both groups, they consistently report that you
> have to know how the rules work before you break them.

Yes. How does that contradict what I said?

There is a huge difference between knowing when to break the rules, and 
avoiding the rules because there might someday be an exception.


>> The language shouldn't make
>> everyone carry the burden of supporting two-page functions all the
>> time, just to save you an insignificant amount of trouble on the
>> vanishingly rare occasion you need a function that is two pages long.
> 
> I don't think there's a particularly big burden there.

Good for you.

 
> Explicit is better than implicit.

Ah, argument by misunderstanding the Zen!


> It is *better* to explicitly mark the
> ends of things than to have it be implicit in dropping indentation. 
> That's not a burden, it's good engineering practice.

Python does explicitly mark blocks. It does it by changes in indentation. 
An indent is an explicit start-block. An outdent is an explicit end-
block. There is nothing implicit in a change in indent level.

To illustrate the difference, this is how a hypothetical language might 
use implicit end of blocks:


if condition:
true_clause()
another_true_clause()
else:
false_clause()


The if block ends implicitly when you reach an else statement, and the 
else clause implicitly ends... where?

It gets worse:

if condition:
if another_condition:
true_clause()
else:
false_clause()
another_clause()


Such a hypothetical language might decide on a rule that else will always 
match the closest if, or the outermost if that is legal. That would be an 
implicit end of block. This is not even within the same galaxy as what 
Python does.

It simply isn't possible to have implicit start/end block markers, unless 
you restrict your language in ways that exclude most blocks. E.g. if all 
if blocks were restricted to a single statement, then you could have an 
implicit block -- the block in one statement. Stating that Python uses 
implicit block markers is simply wrong.


-- 
Steven



More information about the Python-list mailing list