How to use the bash command "read -e variable" and pass the variable to python variable

I would like to pass shell input to a variable in python. Usually I would use the raw_input() method for this, but I would like to use something that allows me to “browse” through my folders.

In a bash script, I would use something like this: (-e allows me to use the shell's “auto-complete” function via Tab.)

 #!/bin/bash echo Please input the path to the file: read -e var echo $var 

Does anyone know how to solve this in Python? I looked at os.popen() and os.system() , but cannot figure out how to use them.

+4
source share
1 answer

The readline module can give you tab completion for raw_input ().

You might want to do something like this .

+4
source

Source: https://habr.com/ru/post/1438947/


All Articles