[Tutor] "x and y" means "if x is false, then x, else y"??

Adam Bark adam.jtm30 at gmail.com
Thu Jul 22 18:33:39 CEST 2010


On 6 July 2010 02:05, Lie Ryan <lie.1296 at gmail.com> wrote:

> On 07/05/10 22:23, Adam Bark wrote:
>
> >
> > I should add that this is how something like:
> >
> > if x != y:
> >     do_something()
> >
> > works, if expects a True or False (this isn't always true but works for
> > comparison operators expressions such as this).
> >
>
> <nit> "if" expects an expression that can be converted to True or False
> by calling its __bool__()/__nonzero__(); in case of missing
> __bool__/__nonzero__, then the object is considered True. </nit>
>
>
Well put, I couldn't decide how to phrase it without adding confusion but
you hit the nail on the head.
Cheers,
Adam.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100722/c8ededd2/attachment-0001.html>


More information about the Tutor mailing list