Search code examples
pythonobjective-ccross-language

Blending languages - Python and Objective-C


I know Objective-C++ can exist because Objective-C and C++ share common ground in C. But how can Objective-C coexist with Python? I know it must be possible because wxPython uses Cocoa to draw interfaces.

I'm writing a card game engine for OS X. It will be able to play more than one game (Klondike, Spider, Free Cell, maybe even Hearts or Poker). It's going to work with Game Center, so I need to have the Cocoa framework available, but I'd like to write a Python API, so I can write the games themselves in Python (because it's easier to use and more dynamic). How would I go about implementing that sort of language blend in my own application?


Solution

  • If a Python application uses compiled external libraries, then this is extending Python. The documentation for doing that is here.

    If a compiled application uses Python for scripting, then this is embedding Python. The documentation for doing that is here.