Get my current path using a python script as a command -


i put python script /usr/local/bin use command in bash.

i want use bash working directory, current directory script executed.

is there way use current directory command does? e.g. convert2ogg (as python script in /usr/local/bin)

$ cd ~/music $ convert2ogg *.mp3 

import os,sys  print("cwd: "+os.getcwd()) print("script: "+sys.argv[0]) print(".exe: "+os.path.dirname(sys.executable)) print("script dir: "+ os.path.realpath(os.path.dirname(sys.argv[0]))) pathname, scriptname = os.path.split(sys.argv[0]) print("relative script dir: "+pathname) print("script dir: "+ os.path.abspath(pathname)) 

this code clear me. os.path not solution problems ;) answer, , seems ask before. first line os.getcwd() solved problem.


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -