Query on fetching the value from specific path using popen

I have a variable where I have stored the path where I have installed the application.

I am using os.popen to check the version of that application but it is always showing default version not the one I am passing.


var = os.open(Test --version).read()

Could anyone know the correct way

Please take care to format the code properly, and make sure it reflects your actual code. Don’t just try to type out an example from memory; make sure you have something that can be run as is (no typos or syntax errors) and that will show the problem you are talking about (since you are not talking about a syntax error).

Making a best guess: I assume you actually have something like

test = "/home/test"

var = os.popen("test --version").read()

with the idea that test is the name of the program, and the variable test also holds a path to a specific version of the program.

Python’s ordinary string literals will not care about any variables that you have in your program. If you want to substitute some variable’s text into a longer string, you have to write code for that explicitly. There are many ways to do this.

Here is a reference on Stack Overflow:

Thank you karl. I am able to fetch the value and the version.

Yeah, this my first time posting any query in form, will take care of formatting.