ammar azif wrote: > Is there any Built-in function to check whether a character is an > ASCII character? > > I am trying to learn event driven programming in python. Heres my code: > > while 1: > key=msvcrt.getch() > if key==255: > continue Here's your problem. >>> import msvcrt >>> msvcrt.getch() '\xff' >>> print '\xff' ΓΏ >>> '\xff' == 255 False >>> ord('\xff') 255 >>> '\xff' == chr(255) True
Do you see? '\xff' is a character, so it's not equal to the integer value 255 (in Python, characters are not the same thing as integers, unlike C++) If you get the ordinal of '\xff' you'll get 255, or if you do chr(255) you'll get '\xff'. You need to use one or the other method in your comparison, or just compare to '\xff'. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor