From the code below both returns me the same output. When should I use one over the other?
import os
from os.path import abspath, dirname
print abspath(dirname(__file__))
print os.getcwd()
PS: I wanted to use this for dynamically changing the path for logs, static files and templates in my django project to run it in different environments.
Use the first when you want to know the location of the file being executed. Use the second when you want to know the process’s current working directory.