Finding name of running script
M.E.Farmer
mefjr75 at hotmail.com
Sun Apr 17 20:16:30 EDT 2005
> print locals()['__file__'].split(sep)[-1]
.split(sep)[-1] is pretty dense reading.
try:
print os.basename(locals()['__file__'])
runes wrote:
> Is it a more pythonic way of finding the name of the running script
> than these?
>
> from os import sep
> from sys import argv
>
> print argv[0].split(sep)[-1]
> # or
> print locals()['__file__'].split(sep)[-1]
> # or
> print globals()['__file__'].split(sep)[-1]
M.E.Farmer
More information about the Python-list
mailing list