[Python-ideas] bool(datetime.time(0, 0))

Antoine Pitrou solipsis at pitrou.net
Tue May 8 13:17:22 CEST 2012


On Tue, 8 May 2012 12:12:05 +0100
Paul Moore <p.f.moore at gmail.com> wrote:
> On 8 May 2012 11:53, Antoine Pitrou <solipsis at pitrou.net> wrote:
> >> If you want to test for None return values, you need to use
> >> "if is None" or "if is not None".
> >
> > So who writes the PEP to deprecate __bool__ methods wholesale?
> 
> I see no need - if you're testing for "true" return values, bool is
> correct. But if you're testing for None vs an actual value, it's not.

Well, again, if that's the case, then __bool__ should be deprecated for
all types where being "true" or "false" doesn't make obvious sense.
Which is most types, actually.

Of course, this is a completely vacuous discussion. The reality is that
a __bool__ exists for all types, we are not deprecating it, and people
rely on it even though PEP 8 zealots may recommend otherwise.

Again, the question is whether time.__bool__ is sane and, if not, why
not make it saner? Lecturing people on style doesn't make Python better.

Regards

Antoine.





More information about the Python-ideas mailing list