Ask coding questions

← Back to all posts
how to get directory path
TheBlockkingBlo (0)

i am asking how to get the directory path because when i have this in my code 'os.chdir('mainprofile.json')' i get this error
'NotADirectoryError: [Errno 20] Not a directory: 'mainprofile.json''

Comments
hotnewtop
GatewayDuckYT (48)

The directory path would be
/home/runner/<project name>/<file path>
like
/home/runner/chat/assets/bob.png
Click the check if this helped
Need more help? just reply to this

GatewayDuckYT (48)

@GatewayDuckYT in js i would do

function getPath(path) {
var path = '/home/runner/<project name/' + path
return path;
}
var path = getPath('bob.png')
TheBlockkingBlo (0)

@GatewayDuckYT I'm using python (discord.py) should have said that sorry

GatewayDuckYT (48)

@TheBlockkingBlo the paths would still be the same

def getPath(path):
   '/home/runner/<project name/' + path
    return path
path = getPath('bob.png')
TheBlockkingBlo (0)

@GatewayDuckYT how would i add os.chdir() into this? (im kinda new with replit sorry)