9 ms·
You are aware that asserting `len(L) == 1` excludes the possibility that it's empty, right? You know what "redundant" means, right?
by jemfinch 16y ago
You are aware that asserting `len(L) == 1` excludes the possibility that it's empty, right? You know what "redundant" means, right?
- statictype 16y agoif L is None then asserting `len(L)==1` throws an exception. The `if L and` part safeguards against that.
- jemfinch 16y agoAnd the point that was made in the other branch of this thread is that if the author intends to guard against None (who knows why?) then he should say, explicitly, "if L is not None". That's what PEP8 recommends precisely to avoid ambiguities such as these.