Command to get the current working directory use:
cwd = os.getcwd()
Command which will get the entire path to the directory where a python file is contained in:
dir_path = os.path.dirname(os.path.realpath(__file__))
Make sure that the spell above won't work on the off chance that you've just utilized os.chdir() to change your present working registry, since the estimation of the __file__ constant is comparative with the current working directory and isn't changed by an os.chdir() call.
Wanna become a python expert? Come and join the python certification course & get certified.