Cleaning up conditionals

Deborah Swanson python at
Fri Dec 30 19:26:43 EST 2016

> On 31 December 2016 at 10:00, Deborah Swanson 
> <python at> wrote:
> >
> > Oops, indentation was messed up when I copied it into the email.
> The indentation of your latest message looks completely 
> broken  now, you can see it here: 

Hm, I don't know what pipermail does with whitespace but the formatting
in the message at
is not the same as the message I sent from Outlook.

Again, it should have been:

if len(l1[st]) == 0:
	if len(l2[st]) > 0:
		l1[st] = l2[st]
elif len(l2[st]) == 0:
	if len(l1[st]) > 0:
		l2[st] = l1[st]

(Maybe keeping the left edge flush with the left margin will help keep
the mail processors straight. I've never tried emailing python code

As Mr. Bieber points out, what I had above greatly benefits from the use
of conjunctions. It now reads:

if not len(l1[st]) and len(l2[st]):
		l1[st] = l2[st]
elif not len(l2[st]) and len(l1[st]):
		l2[st] = l1[st]

(I plead being cross-eyed from rewriting this section so many times for
not seeing this.)

I'm still wondering if these 4 lines can be collapsed to one or two

More information about the Python-list mailing list