runes wrote:
> Thanks!
>
> That's os.path.basename() I guess. It's better, but still complex.
Yea murphy's typo ;)
> I have a
> _nof_ = argv[0].split(sep)[-1] in my script template and use it
under
> the usage() function to tell what the script does, like:
> "cf.py counts files in directory or d
Thanks!
That's os.path.basename() I guess. It's better, but still complex.
I have a
_nof_ = argv[0].split(sep)[-1] in my script template and use it under
the usage() function to tell what the script does, like:
"cf.py counts files in directory or directory structure"
If I change the filename,
> 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(s
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]
--
http://mail.python.org/mailman/listinfo/python-l