[Wenhua Zhao]
> a = b | 1

> a = b if b != nil
> else a =1

> Is there such expression in python?

Hi.  Merely write:

   a = b or 1

In Python, there is no `nil'. `a' will receive 1 instead of the value of
`b' only if `b' is either zero, None, False, or empty in some way.

-- 
François Pinard   http://pinard.progiciels-bpi.ca
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to