[Tutor] or synxtax in if statement

Brian Wisti brian.wisti at gmail.com
Fri Aug 31 23:19:48 CEST 2007


On 8/31/07, David Bear <david.bear at asu.edu> wrote:
>
> I think I want to be lazy and express this
>
> if a == b | a = c
> (if a equal b or a equals c)
> using
>
> if a == b | c
>
> it seems to work.. but I'm not sure if it is correct -- and I haven't seen
> any documentation on using this type of syntax.



You could put b and c in a tuple or array and check for membership

>>> a, b, c = 1, 0, 1
>>> a in (b, c)
True

Is that lazy enough?

Kind Regards,

Brian Wisti
http://coolnamehere.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070831/bf66388f/attachment.htm 


More information about the Tutor mailing list