I was looking for a solution, but have not found what I need.
Script path: /dir/to/script/script.py or C:\dir\script.py
Excepted result:
$ ./script.py
output: /dir/to/script
$ cd .. && ./script/script.py
output: /dir/to/script
Is there any function in os module or something?
I mixed solutions and write:
print os.path.abspath(os.path.dirname(__file__))
But it's ugly. Is there better way?