boolean operations on sets

Thomas Jollans thomas at
Mon Aug 6 17:30:08 CEST 2007

On Monday 06 August 2007, Flavio wrote:
> So My question is: Why has this been implemented in this way? I can
> see this confusing many newbies...

I did not implement this, so I cannot say, but it does have useful 
side-effects, for example:

x = A or B

is equivalent to:

if A:
  x = A
  x = B

also, in python implementations without the (y if x else z) syntax, you can 
use (x and y or z) with nearly the same result*. Also, this implementation of 
and/or might well be faster ;-)

*: this doesn't work the same if y is a false value; (x and [y] or [z])[0] is
   less readable, but works for all y

      Regards,                       Thomas Jollans
GPG key: 0xF421434B may be found on various keyservers, eg
Hacker key <>:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the Python-list mailing list