Can xcode compile Python?

Discussion in 'Mac Programming' started by MythicFrost, Jan 3, 2010.

  1. MythicFrost macrumors 68040

    MythicFrost

    Joined:
    Mar 11, 2009
    Location:
    Australia
    #1
    Hey I'm learning Python and I'm wondering, can XCode compile it? I have an empty file open right now and have set the syntax colouring to python.
    But can it compile and run it? Thanks.
     
  2. RaceTripper macrumors 68030

    Joined:
    May 29, 2007
    #2
    Python is an interpreted language. It does not compile. You can run scripts written in Python from Terminal using the python interpreter.

    Whether or not you can setup XCode to execute python scripts I can't answer.
     
  3. larkost macrumors 6502a

    Joined:
    Oct 13, 2007
    #3
    Just for the record, you can also create full Cocoa-interfaced applications written in Python. XCode used to even include templates for building these applications, but they are gone now from the latest version of XCode[1]

    But RaceTripper is right for almost every case: you don't really think about compiling Python[2], but rather it gets interpreted at runtime.

    I generally write stand-alone python in SubEthaEdit (substitute your favorite editor here), and only use XCode when I am writing Cocoa-Python applications.

    [1] I filed a bug on this with Apple when it happened, but their response was that this was "as expected" and that I could take the templates from older versions of XCode and they would work (this is true).

    [2] There are two exceptions to this: 1) There are compilers that will take Python code and translate it into native executables. But people don't often do this in most cases. 2) Python modules are compiled into a bytecode that makes them more efficient to run. But Python takes care of that in the background so you don't generally have to worry about it.
     

Share This Page