473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Re: very rare python expression

Nothing strange about that syntax (though some spaces might helped you out).

The '&' operator is a bit-wise operator
(http://docs.python.org/ref/bitwise.html).

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

# 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
--
http://mail.python.org/mailman/listinfo/python-list

Aug 12 '08 #1
0 1161

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
8
by: Paul Cochrane | last post by:
Hi all, I've got an application that I'm writing that autogenerates python code which I then execute with exec(). I know that this is not the best way to run things, and I'm not 100% sure as to...
25
by: Byte | last post by:
I know this is probably a stupid question, but I'm learning Python, and am trying to get the if function to work with letters/words. Basicly, I'm trying to write a script that when run, says ...
5
by: =?GB2312?B?zPC5zw==?= | last post by:
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:...
0
by: Tim Golden | last post by:
甜瓜 wrote: 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 meaning:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.