Platform-independent way to refer to execute path

Skip Montanaro skip at
Wed Jun 25 17:27:20 CEST 2003

    MK> What would be the best platform-independent way to refer to the
    MK> current (execute) path for a Python script?

How about:

    #!/usr/bin/env python

    import os
    import sys

    print os.path.dirname(sys.argv[0])


More information about the Python-list mailing list