I come from a R background and now want to learn Python. I run Python using RStudio and want to show the directory of where the current python script is located. For this I followed this tutorial. I have this script:
import os
result = os.path.join(os.path.dirname(__file__))
print(result)
When I execute it I get this result:
>>> import os
>>> result = os.path.join(os.path.dirname(__file__))
NameError: name '__file__' is not defined