[openstack-dev] [nova] 'if foo' vs 'if foo is not None'
Andrew Laski
andrew.laski at rackspace.com
Mon Mar 3 15:41:32 UTC 2014
On 03/03/14 at 03:00pm, Matthew Booth wrote:
>PEP 8, under 'Programming Recommendations' recommends against implicit
>comparison to None. This isn't just stylistic, either: we were actually
>bitten by it in the VMware driver
>(https://bugs.launchpad.net/nova/+bug/1262288). The bug was hard to
>spot, and had consequences to resource usage.
>
>However, implicit comparison to None seems to be the default in Nova. Do
>I give up mentioning this in reviews, or is this something we care about?
From what I've seen I don't think it's implicit comparison to None so
much as it's considering None and things like [] to be equal. Because
there is a risk of bugs, and I've seen others beyond the one linked
above, I think it's worth pointing out in a review. But the context has
to be taken into account as sometimes it's legitimate to consider None
and [] to be equal.
>
>Matt
>--
>Matthew Booth, RHCA, RHCSS
>Red Hat Engineering, Virtualisation Team
>
>GPG ID: D33C3490
>GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
>
>_______________________________________________
>OpenStack-dev mailing list
>OpenStack-dev at lists.openstack.org
>http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
More information about the OpenStack-dev
mailing list