Get path where python file is called

Asked

Viewed 969 times

1

I created a python file and made it available to access from every place on the system, however, for many applications accurate the path where the python file was called by the system, but I did not find on the internet any way to get this value, someone can help me?

  • Ideally, you’d put part of your code to help identify problems/solutions (en.stackoverflow.com/help/mcve)

  • It would be something like: os.path.realpath(__file__) ??

1 answer

2

You can use the method getcwd library the

It returns your current working directory

import os
print(os.getcwd())

See working on Repl.it

If you want to read some more: the getcwd.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.