I want to get the directory that my current .py file is saved in so that I can set the current working directory to this directory programmatically. Like:
import os
file_path = ???
os.chdir( file_path )
I thought you could use __file__
to achieve this, but it says name '__file__' is not defined
.