Does python support the expression "a = b | 1"???

Grant Edwards grante at visi.com
Wed Oct 5 21:15:52 CEST 2005


On 2005-10-05, Wenhua Zhao <whzhao at gmail.com> wrote:

> a = b | 1

Yes, Python supports that expression.

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

But that's not what it means.

> Is there such expression in python?

>>> b=0
>>> b = 0
>>> a = b | 1
>>> a
1
>>> b = 1
>>> a = b | 1
>>> a
1
>>> b = 2
>>> a = b | 1
>>> a
3
>>> 

I'm not sure what What you mean by "nil", but I would geuess
this is the equivalent Python:

if b is not None:
  a = b
else:
  a = 1

-- 
Grant Edwards                   grante             Yow!  .. Do you like
                                  at               "TENDER VITTLES?"?
                               visi.com            



More information about the Python-list mailing list