python - Help with filetype association! -


i have actual association part down, when open file associated python program, how filepath of file opened?

i think sys.argv? returns path python program, not associated file.

the contents of sys.argv platform-dependent, noted in sys.argv. know sys.argv[0] full path on windows when open .py files using shell double-clicking on it. using command line results in script name.

the os module provides platform-independent solutions. full path script should available following code:

import os.path import sys  print os.path.abspath(sys.argv[0]) 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -