very rare python expression

Tim Golden mail at
Tue Aug 12 11:16:22 CEST 2008

甜瓜 wrote:
> 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.

Well I can't say I'd format it that way myself,
but it is valid. More conventionally laid out
the expression looks like this:

x & 528 or x in l


if x & 528:
   return True
elif x in l:
   return True
   return False

where x & 528 is the bitwise combination of x with 528.

Obviously the code you quote is taking the logical inverse
of this expression - "while not (...)"


More information about the Python-list mailing list