September 30th, 2004, 11:05 AM
Green and red snakes!
I have a very basic question. I'm not sure why some of the symbols for my python programs show as a red snake, and most others as green ones. When I check the properties of these red ones, it says "compiled", but I thought python programs are not compiled and are interpreted.
Thanks for your help,
September 30th, 2004, 11:25 AM
Green files are plain text Python files ending in .py or .pyw - These are the source code files you can edit in IDLE or textpad.
The Redfiles are the bytecode versions of the same code. They can be run just like the green files but you can't edit them in IDLE.
Before a Python file can be run it is converted (compiled) to bytecode. To avoid having to do the conversion each time the program is run; the bytecode is saved in the .pyc file (red file).
September 30th, 2004, 11:40 AM
Thanks alot, very well explained.
September 30th, 2004, 11:42 AM
What's the .pyw extension used for by the way?
September 30th, 2004, 11:55 AM
A .pyw file does not have a console window (DOS box) so all user IO is a GUI.
Some more info here:
October 3rd, 2004, 03:44 PM
When you run a Python program, the modules, which are imported by that program are converted to byte code (.pyc and .pyo files). As Grim mentioned above. The program itself isn't implicitly converted (to a .pyc file).