Deprecate tabs for indenting (was Re: Indenting with tabs vs spaces)

Bjorn Pettersen BPettersen at NAREX.com
Wed Dec 5 12:20:57 EST 2001


> From: Courageous [mailto:jkraska at san.rr.com] 
> 
> >Can you give an example of how spaces must creep in on continuation 
> >lines?
> 
> ##--snip; not in particular the column-positioning of the "or". If
> ##        tabs are used here, it will be misaligned with other
> ##        tabstop stettings for certain
> 
>     if isinstance(f, future.Step)          or \
>        isinstance(f, future.Status)        or \
>        isinstance(f, future.Announce)      or \
>        isinstance(f, possibility.Observe)  or \
>        isinstance(f, future.Incarnate)     or \
>        isinstance(f, future.Start)         or \
>        isinstance(f, future.Timeout):

Ack, so much typing :-)

 klasses = [future.Step, future.Status, ...]
 if filter(lambda x: isinstance(f,x), klasses):

> ##--snip; in this case, the continuation line is lined up on the
> ##        string boundary to create some congruity between the code
> ##        and the message produced
> 
>     log.Fatal("Unexpected RETURN intercepted from user code.\n"
>               "This is almost certainly due to an 
> inappropriate explicit\n"
>               "or implicit use of return in an Task. HINT: 
> Make sure\n"
>               "to use Fail(), End(), or Succeed() to 
> terminate a Task,\n"
>               "The most suspicious task is probably this 
> one:\n\n"+lastFuture.String())

Ugly...

  txt = """
     Unexpected RETURN intercepted from user code.
     This is almost certainly due to an inappropriate 
     explicit...
  """
  log.Fatal(txt)

> ##--snip; here, like the or, the actions are put into a column.
> ##        simple actions, organized like this are both compact and
> ##        readable.
> 
>         if methodname==self.task.name:         methodname="-"
>         else:                                  
> methodname=methodname[0:20]+"()"
>   
>         if self.task.status:                   
> stat=status.strings[self.task.status]
>         else:                                  stat="UNKNOWN"
> 
>         if self.absoluteT == simulator.ticks:  when="now"
>         else:                                  when="future"

If anyone writes code like that on any of our projects they'll be shot
<wink>. When one of the if tests change it usually causes a cascading
re-indent of the second column.

We use tabs exlusively for all our projects, and in practice there is
never a problem getting things to line up (I guess as with the
"whitespace-for-indentation" issue you'll have to try it before you
believe it).

-- bjorn




More information about the Python-list mailing list