#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    330
    Rep Power
    15

    Green and red snakes!


    Hello,

    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,
    Sam K.
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    Hey sam,

    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).

    grim
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    330
    Rep Power
    15
    Thanks alot, very well explained.

    Sam K.
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    330
    Rep Power
    15
    What's the .pyw extension used for by the way?

    Sam K.
  8. #5
  9. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14

    A .pyw file does not have a console window (DOS box) so all user IO is a GUI.
    Some more info here:
    http://forums.devshed.com/t187633/s.html

    grim
  10. #6
  11. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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).
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo