Carl Banks pavlovevidence at gmail.com
Mon Oct 12 00:05:24 CEST 2009

On Oct 11, 7:10 am, Grant Edwards <inva... at invalid.invalid> wrote:
> On 2009-10-11, metal <metal... at gmail.com> wrote:
> > I wonder the reason for ELIF. it's not aligned with IF, make code ugly
> It most certainly is aligned with IF:
>   if cond1:
>       do this
>   elif cond2:
>       do that
>   else:
>       do the other
> The "if" "elif" and "else" are all aligned in all of the code
> I've ever seen.

The condition in the elif clause is two columns to the right of the
condition in the if clause.

It's a silly thing to worry about, in fact the slight visual
distinctness of it probably helps readability.  Some people do get
finicky about columns and try to line things up all the time.  It's
frustrating, wasteful, and ultimately hopeless, and sometimes
deceptive (lining things up can suggest relationships where none
exists) so I make it a point not to do it, however prettier it'll make
those two lines.

Carl Banks

More information about the Python-list mailing list