Local access to a file, How To ?
On 2020-07-28 21:56, Steve wrote:
> I have a python program that reads and writes to files that are all within
> the folder that contains the python program. There is now a second python
> program that is to be run to compile information in said files.
> I am having difficulty trying to call the local supporting program from
> within the main program. I would it would found easily because everything
> is all in the same folder. Apparently, I have to decipher paths to do the
> One problem is that the project is portable on a thumb drive and the path
> can change based on the computer on which the program is executed. I look
> up use of path and I seem to get all absolute path instruction and not
> Where an I steering wrongly here.
It's easiest to work with absolute paths.
The path of the script is given by __file__, so the folder in which the
script is running is given by os.path.dirname(__file__).
You can work from there to make the paths of the other files using