Using PyObjC, is it possible to import a Python module, call a function and get the result as (say) a NSString?
For example, doing the equivalent of the following Python code:
import mymodule
result = mymodule.mymethod()
..in pseudo-ObjC:
PyModule *mypymod = [PyImport module:@"mymodule"];
NSString *result = [[mypymod getattr:"mymethod"] call:@"mymethod"];
As mentioned in Alex Martelli’s answer (although the link in the mailing-list message was broken, it should be https://docs.python.org/extending/embedding.html#pure-embedding).. The C way of calling..
External Frameworks..,Add > Existing Frameworks. The framework in in/System/Library/Frameworks//System/Library/Frameworks/Python.framework/Headersto your “Header Search Path” (Project > Edit Project Settings)The following code should work (although it’s probably not the best code ever written..)
Also this tutorial is good