Is there any short way to achieve what the APT (Advanced Package Tool) command line interface does in Python?
I mean, when the package manager prompts a yes/no question followed by [Yes/no], the script accepts YES/Y/yes/y or Enter (defaults to Yes as hinted by the capital letter).
The only thing I find in the official docs is input and raw_input…
I know it’s not that hard to emulate, but it’s annoying to rewrite 😐
As you mentioned, the easiest way is to use
raw_input()(or simplyinput()for Python 3). There is no built-in way to do this. From Recipe 577058:(For Python 2, use
raw_inputinstead ofinput.)Usage example: