I was looking for a solution, but could not find what I needed.
Script path: / dir / to / script / script.py or C: \ dir \ script.py
Excluded result:
$ ./script.py output: /dir/to/script $ cd .. && ./script/script.py output: /dir/to/script
Is there any function in the os module or something like that?
I mixed solutions and write:
print os.path.abspath(os.path.dirname(__file__))
But it is ugly. Is there a better way?
Mateusz Jagiełło
source share