So this tutorial is a lot more than just the sample code. While you probably can just get by with the others without watching the video, this one is going to probably make no sense without the video. That said:
# This tutorial is best followed in a shell / command prompt. # Open yours up, type python, or python3, and then follow. import subprocess # Say you are on windows: # module call command in the shell # you can change that if you'd like, eventually. # IF YOU ARE NOT IN A SHELL, YOU WILL SEE NO OUTPUT! subprocess.call('dir', shell=True) subprocess.call('echo dir', shell=True)
So what we're able to do here is communicate to the shell commands from our Python script. The reason this matters is for the same reason that we can communicate from the shell to Python. We can communicate from the shell to Python as we saw earlier, and now we see we can communicate from Python to the shell.
What makes this special, is when you realize that you can do this same thing with other languages as well. So, you can use, say, java to communicate with the shell, which then passes vars through to a python script, which then communicates back to the shell, which then goes back into the java program... or any program. You can achieve similar results with sockets as well, and it will come down to performance and preference which you choose. I find this method to be far easier, but sometimes more clumsy.
Anyway, hopefully you enjoyed.