Crashing Games

This is probably the most rookie question ever but quite a few of the games I've played have crashed on a line like this:

os.path.dirname(__file__)

I run Windows 7, python 2.6 and pygame 1.9, dunno whats happening but clearly I am missing something here. I get the following error:

Traceback (most recent call last):
  File "C:\Users\Ben\Desktop\NineDisasters-0.0.1\run_game.py", line 5, in <module>
    here = os.path.abspath(os.path.dirname(__file__))
NameError: name '__file__' is not defined

(log in to comment)

Comments

Are you running a game bundled with py2exe? I gather that it has some quirk involving the __file__ attribute, such as not setting it for the main module or something like that.