I'm learning how to locate directories in Python and I came across the following code:
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
print(dir_path)
cwd = os.getcwd()
print(cwd)
Why does the Python language use __file__
to refer to the current file?
How does this command relate to all syntax?
What is the disadvantage in using os.getcwd()
?