Forums

Current directory

What the way to return the directory where the Python program is located? For example, on a local computer, you'd use os.getcwd() but on PythonAnywhere that line would return 'home/username'

We usually use something like this:

os.path.dirname(os.path.abspath(__file__))

os.path.dirname(os.path.abspath(file))