Question about indentation and bugs

Steve Holden sholden at holdenweb.com
Thu Aug 23 19:36:59 EDT 2001


"Dave Swegen" <dswegen at allstor-sw.co.uk> wrote in message
news:mailman.998577160.2781.python-list at python.org...
> 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
>
Well, if you read your post above as my mailer showed it to me you will
realise that braindead mail software *can* magle Python: Outlook Express
does not render tabs (at least, I can't find a way to make it), so your two
examples ended up the same!

Despite this, in practice there are few problems of this nature. Tell your
colleagues not to worry.

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list