very rare python expression

甜瓜 littlesweetmelon at gmail.com
Tue Aug 12 04:39:27 EDT 2008


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.

# snake.py code:
import pygame as p,random
p.init()
q=p.display
T=16
b=q.set_mode([256]*2).fill
l=[]
d=a=x=1
c=p.event.get
while not(x&528or x in l):
 l=l[a!=x:]+[x]
 while a&528or a in l:a=random.randrange(512)
 b(0)
 [b(99,(o%T*T,o/32*T,T,T))for o in l+[a]]
 q.flip()
 p.time.wait(199)
 for e in c(2):
  v=e.key-272
  n=((v&2)-1)*[1,32][v<3]
  if-n-d and 0<v<5:d=n
 c()
 x=l[-1]+d


Best regards,

--
ShenLei



More information about the Python-list mailing list