Question about indentation and bugs

Dave Swegen dswegen at allstor-sw.co.uk
Thu Aug 23 10:28:05 EDT 2001


First of all this is not intended as flame-baiting or trolling. I'm
genuinly curious about this one weird feature.

I've recently started looking at python, as we are about to implement a
whole new intranet, and it would seem that basically all web tools that
are of interest (zope, mason etc) are either perl or python based. 

Now, I've done a bit of perl coding, and it does have some neat
features. However, I feel that there are far too many cases where making
hard-to-read code is too easy, or things feel tacked on (OOP, for
instance). That is why I really like what I've seen of Python so far.

However, I (and others here at work) do have some real concerns about
the indentation feature. Basically we are quite worried about subtle
but nasty bugs creeping in. Take the following code for instance:

for i in [1234]:
	print i
	print "hello"

Perfectly fine, valid code. But one indentation step wrong, and you end
up with perfectly fine, valid code that does something else, ie

for i in [1234]:
	print i
print hello

I imagine that these sort of problems might not only appear due to
incorrect coding, but also things such as broken mailers, applying
patches from people using different indent levels etc

So my question (or rather questions) is this: In practice, how often do
such problems crop up?  How does one go about avoiding such problems? Is
there any way at all to make explicit where a block ends?

Any points of view much appreciated

Cheers
	Dave




More information about the Python-list mailing list