Created
June 7, 2013 00:52
-
-
Save kgriffs/5726314 to your computer and use it in GitHub Desktop.
Disable echo in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def enable_echo(enable): | |
fd = sys.stdin.fileno() | |
new = termios.tcgetattr(fd) | |
if enable: | |
new[3] |= termios.ECHO | |
else: | |
new[3] &= ~termios.ECHO | |
termios.tcsetattr(fd, termios.TCSANOW, new) | |
atexit.register(enable_echo, True) | |
enable_echo(False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment