You really want this function in Python, I guess. Here are two relevant links I found, knowing nothing about getchar; I bet you will be able to do better.