Adding a __filename__ predefined attribute to 2.5?

Diez B. Roggisch deets at nospam.web.de
Wed Oct 12 04:02:28 EDT 2005


Rune Strand wrote:
> I Steve,
> 
> 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.

What overhead? Besides: if you want to do python this, why don't we 
introduce the function

solve_my_problems()

that is the only thing a programmer has to invoke... Seriously: Just 
because you have a usecase for __filename__ doesn't mean everybody else has.

> Currently I have this in my scripts:
> __filename__ = __file__.replace('\\', '/').rsplit('/', 1)[-1]

This is neither platform independent nor less "overhead". This is:

import os
__filname__ = os.path.split(__file__)[-1]



Diez



More information about the Python-list mailing list