Expression can be simplified on list

Chris Angelico rosuav at gmail.com
Mon Sep 12 17:57:55 EDT 2016


On Tue, Sep 13, 2016 at 7:21 AM, Thomas 'PointedEars' Lahn
<PointedEars at web.de> wrote:
> If I knew that it is always going to be a list or a tuple, I would check its
> length instead:
>
>   if len(errors) == 0:

I wouldn't. I'd use boolification here too. Only if I had to
distinguish between None, [], and [1,2,3], would I use a more explicit
check (and it wouldn't be "== []", it would be probing for None).

ChrisA



More information about the Python-list mailing list