printing problem
sanjay pradeep
sanjay08544 at yahoo.com
Thu Mar 2 19:09:02 EST 2000
hi i want to grab 3 characters and print
them out as they are entered with no space in
between. the following program waits till
all 3 characters are printed, and then prints,
which is close to what i want but not quite.
#!/usr/local/bin/python
# import posix
import string
import curses
def reader():
win = curses.initscr()
s = win.getch('noecho')
# tty-example-2.py
import sys
try:
# windows or dos
import msvcrt
getkey = msvcrt.getch
except ImportError:
# assume unix
import tty, termios, TERMIOS
def getkey():
file = sys.stdin.fileno()
mode = termios.tcgetattr(file)
try:
tty.setraw(file, TERMIOS.TCSANOW)
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(file, TERMIOS.TCSANOW,
mode)
return ch
def main():
horky=['y','e','s']
borky=horky
alpha=range(3)
for count in alpha:
jerk=getkey()
print jerk,;sys.stdout.softspace=0;
borky[count]=jerk
main()
thanks!
sanjay
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com
More information about the Python-list
mailing list