On Nov 28, 12:55 pm, Erik Max Francis <m...@alcyone.com> wrote: > moijes12 wrote: > > I know the value -0 is quite meaningless and makes little sense.But I > > was just fiddling.I am unable to figure out the below result > > >>>> -0 and True > > 0 ----------> (Why is this 0 and not say True or False) > >>>> -0 and false > > 0 > >>>> -0 or True > > True > > > Could someone please provide me some resources on how these operations > > take place.I'd wanna find it out myself > > Your questions have nothing to do with -0, as it's no different from 0: > > >>> 0 == -0 > True > > Your examples work the same way with simply 0, which is considered a > false value: > > >>> bool(0) > False > >>> 0 and True > 0 > >>> 0 and False > 0 > >>> 0 or True > True > > What you're seeing is simply the short-circuiting behavior of the `and` > and `or` operators; they return the last (relevant) value they > encountered before making their determination of the value of the > overall expressions. See python.org/doc for more information. > > -- > Erik Max Francis && m...@alcyone.com &&http://www.alcyone.com/max/ > San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis > You'll survive / A true Darwin star > -- Des'ree
Thanks Erik -- http://mail.python.org/mailman/listinfo/python-list