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
else:
  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 pgp.mit.edu
Hacker key <http://hackerkey.com/>:
v4sw6+8Yhw4/5ln3pr5Ock2ma2u7Lw2Nl7Di2e2t3/4TMb6HOPTen5/6g5OPa1XsMr9p-7/-6

Attachment: signature.asc
Description: This is a digitally signed message part.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to