"0 in [True,False]" returns True

bonono at gmail.com bonono at gmail.com
Tue Dec 13 05:48:59 EST 2005


Fredrik Lundh wrote:
> Duncan Booth wrote:
>
> > Another reason to have a boolean type is of course to provide a cast:
> >
> >    def isNameSet(self):
> >       return boolean(self.name)
> >
> > instead of:
> >
> >    def isNameSet(self):
> >        if self.name:
> >           return True
> >        else:
> >           return False
>
> given that Python already had a function for this, that wasn't
> much of a reason:
>
> >>> help(operator.truth)
> Help on built-in function truth in module operator:
>
> truth(...)
>     truth(a) -- Return True if a is true, False otherwise.
>
> (truth returned 1 or 0 in pre-boolean versions)
>
I see you skip another use case of XMLRPC Duncan mentioned, is that a
valid reason ?




More information about the Python-list mailing list