Thursday, 15 April 2010

python - Confusion found with and operator -



python - Confusion found with and operator -

this question has reply here:

does python back upwards short-circuiting? 3 answers

i next output and operator

code

>>>0 , [] 0 >>>[] , 0 [] >>> 0 , '' 0 >>>'' , 0 ''

i not figure out on basis m getting different result on basis of placing of elements..

from the docs on and:

the look x , y first evaluates x; if x false, value returned; otherwise, y evaluated , resulting value returned.

in case, because 0, '', , [] evaluate false, first value in each of expressions beingness returned.

python operator-keyword

No comments:

Post a Comment