user input - Can Python Accept Ctrl+[char] using raw_input? -


i writing command line interface in python accepts lot of user input. values querying user about, there significant amount of "additional information" display, rather display if user needed how provide value.

so thought provide usual raw_input prompt, try accept ctrl-h type sequences output info.

can python accept kind of input via raw_input in terminal/shell? there more proper way (preferably in stdlib)?

no, python cannot accept kind of input through raw_input. because you're thinking sequences like: ctrl-c, ctrl-z, etc. these not keyboard inputs, these signals processed terminal (not program).

you can try set signal handlers you, not reliable solution (regardless of whether you're using python or else).

the best solution accepting kind of input either use curses, or use readline (with adjustments configuration handle things ctrl-h). using readline make life easier, comes cost have license program under gnu gpl (or similar). whereas curses not have kind of restriction.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -