While logged in as "standard" pi user, I am expecting the path to the user directory to be /home/pi – which is the case when I open File Manager, for example. However, when I run this script I get /root instead of the expected /home/pi:
import os homedir = os.path.expanduser("~") print (homedir)
Is my assumption wrong ?
What (else) should I use to get the pi user directory ?
Edit: I found the answer by myself: this happens because I am running the Python script prefixed with sudo. Sorry for confusion.