I'm very new to programming, and to Python. I'm on Mac OSX, trying to work with PyCharm. I've looked at this, this, this, and several more.
But I can't seem to get the path of the current running file. If I use os.getcwd()
, I get
'/Users/AlanH/Python'
When really, the full file path is:
'/Users/AlanH/Python/Exercises/PythonBasics/starthere.py'
So I don't understand why that doesn't work.
If I try using sys.path[0]
, it prings up a path that takes me to my Library, then dives in to Enthought (don't know why, even though I'm using Anaconda distribution).
I could go on and on about all the possible solutions I've tried, but nothing works. All I want is to get the exact path up to current running file. So either
'/Users/AlanH/Python/Exercises/PythonBasics/starthere.py'
or this
'/Users/AlanH/Python/Exercises/PythonBasics'
will do.
Could someone please help?