very rare python expression

Wojtek Walczak gminick at nie.ma.takiego.adresu.w.sieci.pl
Tue Aug 12 11:05:33 CEST 2008


Dnia Tue, 12 Aug 2008 16:39:27 +0800, =?GB2312?B?zPC5zw==?= napisa³(a):
> Howdy everyone,
>
> I saw a strange python code in pygame project. What does "while
> not(x&528or x in l):" mean? Below code works in python2.5, so "x&528"
> is not HTML strings.

It looks like a check if 528 flag is set. In this way you can set
more than one flag in signle variable:

>>> flag1 = 1
>>> flag2 = 2
>>> flag3 = 4
>>> flag4 = 8
>>> flag5 = 10
>>> flags_set = flag2 | flag4
>>> flags_set & flag1
0
>>> flags_set & flag2
2
>>> flags_set & flag3
0
>>> flags_set & flag4
8
>>> flags_set & flag5
0


-- 
Regards,
Wojtek Walczak,
http://www.stud.umk.pl/~wojtekwa/



More information about the Python-list mailing list