Q:

How does IDLE run a .py module?

Windows 7 and Python v2.7.3
With this module "test.py":
print 'name: ' , __name__
print 'file: ' , __file__

I can go to CMD and type: python test.py 
The result would be:
name: __main__
file: test.py

But if I open the file with IDLE and press F5 to run the program I'll get a NameError telling me __file__ is not defined.
What steps does IDLE go through to run a .py module, and how is it different from running modules directly from command line?

A:

That's a bug, which has apparently (I don't use IDLE) now been fixed - the discussion of the bug at that link has some explanation of what IDLE actually does to run your code.

