On Thu, 2014-08-07 at 17:41 +0100, Matthew Booth wrote: > ... or arg is an object which defines __nonzero__(), or defines > __getattr__() and then explodes because of the unexpected lookup of a > __nonzero__ attribute. Or it's False (no quotes when printed by the > debugger), but has a unicode type and therefore evaluates to True.
If you're passing such exotic objects as parameters that could potentially be drawn from configuration instead, maybe that code needs to be refactored a bit :) > However, if you want to compare a value with None and write 'foo is > None' it will always do exactly what you expect, regardless what you > pass to it. I think it's also nicer to the reviewer and the > maintainer, > who then don't need to go looking for context to check if anything > invalid might be passed in. In the vast majority of cases, however, we use a value that evaluates to False to indicate "use the default", where "default" may be drawn from configuration. Yes, there are cases where we must treat, say, 0 as distinct from None, but when we don't need to, we should keep the code as simple as possible. After all, I doubt anyone would seriously suggest that we must always use something like the "_unset" sentinel, even when None has no special meaning… -- Kevin L. Mitchell <kevin.mitch...@rackspace.com> Rackspace _______________________________________________ OpenStack-dev mailing list OpenStackfirstname.lastname@example.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev