How to get path of a .py script

James Kew james.kew at btinternet.com
Wed Dec 11 18:07:48 EST 2002


"Manuel M. Garcia" <mgarcia at cole-switches.com> wrote in message
news:9tvevugeb34s6sqigh8a32thljjepnk40a at 4ax.com...
>
> print os.path.split(os.path.realpath(p))

But be aware that os.path.realpath isn't available pre-2.2 or off-Unix.

(And if you want to be really picky about sys.argv[0] -- as I just was,
sorry Pádraig -- "it is operating system dependent whether this is a full
pathname or not".)

--
James Kew
james.kew at btinternet.com





More information about the Python-list mailing list