In a recent post I gave a programmatic solution to how to get Python to write files in the same folder as the Python file itself when working in VS Code. By default, Python programs in VS Code write files in the root folder of the project, not in the folder where the Python file is saved.
My solution involved the use of a built-in variable named “__file__
“, which together with some fancy path concatenation, achieved what I was hoping for.