Walkman100 / NumeralConverter

Convert between Arabic Numerals and Roman Numerals
MIT License
1 stars 0 forks source link

[Python Impl.] Single key input #2

Closed Walkman100 closed 8 years ago

Walkman100 commented 8 years ago

In porting NumeralConverter to python, I haven't found a way to read a single character from STDIN - DotNet has:

pressedKey = Console.ReadKey().Key.ToString

Whereas python27 only has

line_of_input = raw_input("Prompt: ")

which waits for a \n before continuing.

Walkman100 commented 8 years ago

Looking at: https://stackoverflow.com/q/510357/2999220

I have tested:

line_of_input = sys.stdin.read(1)

but this does the same as raw_input(), except it only returns the first character.

Walkman100 commented 8 years ago

http://rosettacode.org/wiki/Keyboard_input/Keypress_check#Python has a windows-only solution