Is a python script aware of its stored location path? -



Is a python script aware of its stored location path? -

/home/bar/foo/test.py:

i trying test.py print /home/bar/foo irrespective of run script from:

import os def foo(): print os.getcwd()

test run:

[/home/bar $] python /home/bar/foo/test.py # echoes /home/bar [/tmp $] python /home/bar/foo/test.py # echoes /tmp

os.getcwd() not function task. how can done otherwise?

try this:

import os.path p = os.path.abspath(__file__)

python

Comments

Popular posts from this blog

java - How to pass parameters between Request-Scoped Controllers? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -

string - what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++? -