Create a gist now

Instantly share code, notes, and snippets.

@echo --- testing ---
@echo Should all return:
@echo %~dp0
@echo #1
@cd /D %~dp0
@echo #2
@cd /D %~dp0
@echo #3
@cd /D c:\
@echo #4
@cd /D %~dp0
python -c "execfile('')"
import sys, os, os.path, inspect
if '__file__' not in locals():
__file__ = inspect.getframeinfo(inspect.currentframe())[0]
print os.path.dirname(os.path.abspath(__file__))

If you uncommnt os.chdir, the test will fail. Is there any workaround for this that is not dependent of current running directory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment