Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6839

Python • Re: Entering digits without pressing "Enter'

$
0
0
This topic has come up many times, but it is difficult to search for unless you already know that the traditional name for a function that reads a single input character without line buffering is getch().

My version in a post over ten years ago: viewtopic.php?t=69046#p502895
OK, so there is no built-in "Pytthonic" way to do it. You have to brute it out just you would like in C.

It occurs to me that the easiest way to get this working might be to have a bash shell wrapper in the mix somewhere, and use the "read" built-in, which can do this sort of thing (using the "-n" switch).

In bash, I routinely use "read -sn1" to get a single character w/o echo.
You could put that in a loop to get 6 characters, and do whatever line editing you felt like coding up.

Statistics: Posted by BigRedMailbox — Thu Jul 25, 2024 3:25 pm



Viewing all articles
Browse latest Browse all 6839

Trending Articles