Rune Strand wrote: > I know it's several ways to isolate the filename. I just want to avoid > the overhead of importing sys or os to achieve it.
those modules are already imported when Python gets to your code, so the only "overhead" you're saving is a little typing. > Currently I have this in my scripts: > __filename__ = __file__.replace('\\', '/').rsplit('/', 1)[-1] wow. that's one lousy optimization... here's a *shorter* piece of code, which is also readable and portable, and a lot easier to type on most keyboards: import os __filename__ = os.path.basename(__file__) </F> -- http://mail.python.org/mailman/listinfo/python-list