Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MythicFrost

macrumors 68040
Original poster
Mar 11, 2009
3,944
40
Australia
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.
 
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.
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.