HP Forums

Full Version: How to specify full directory path in Python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Whenever I run something like

import uio

with uio.open('/Python.hpappdir/main.py', 'r') as mainPy:

it gives me OSError: 0, which from my experience translates to "file not found"

I was wondering how I am supposed to format a directory on the Prime.
Reading from the file section of the python app I was able to use

with open("test.txt",'r',encoding = 'utf-8') as f:


with open("test.txt",'w',encoding = 'utf-8') as f:

wrote the file to the file section of the app

looks like the main.py is stored there to some maybe if you add "Files" to the path
What if I want to open files from different apps, or if I want to access file in the root directory, like cas.hpesettings, or any of the PPL programs? How to I format the path for stuff like that?
I was not involved with this part, but I am quite certain that the "root" directory for the python code will be considered to be inside the app... security concerns and stability being the primary drivers I would assume. Probably cannot access without some sort of path traversal bug.
Is it possible to access files from other apps using sys.path?
Reference URL's