views:

50

answers:

1

Is it possible for an objective c application to run python files and read their data, ect?

If so, can someone post code? or lead me in the right direction?

Thanks, Elijah

+1  A: 

Sure, see the tutorial -- it's very dated but should still apply today. (Apple's tutorial is good, but it only shows how to call ObjC from Python, while pyobjc's own tutorial, while extremely short, focuses on the opposite direction -- calling Python from ObjC -- which appears to be what you want).

Alex Martelli
Now, if I wanted to control HOWIE (pyaiml chat bot http://howie.sourceforge.net/) with objective c, how would I do that? I want to make a GUI for HOWIE. BUT, I don't want to use terminal as an interface, I want the GUI to be the interface to get HOWIE's responses and send input.
Elijah W.
I don't know howie (nor does it interest me enough to study it;-) but at worst you can control it with `pyexpect` and write the whole Mac GUI with Xcode, Cocoa, and Python (with PyObjC -- see Apple's tutorial I already pointed to) -- absolutely no need to "run Python code" from "an objective C application";-). Or, instead of pyexpect, you can look inside howie and use or make a decent Python API for it -- but, again, what does that have to do with objective-c?!
Alex Martelli
Ok...I'll look into that... I need to use objc because, I know objective c and I don't know python. In addition, there are somethings that only objective c can do, and python can't(I think). It seems like you're an expert with python, do you mind giving me an email at drummerboyx(at)verizon(dot)net?
Elijah W.
@Elijah, yep, I'm pretty experienced in Python, but what little free time I have I spend responding on Stack Overflow (where my answers can hopefully be read and used by many people), not on 1-on-1 help which just doesn't scale -- sorry. If you don't know either Python or Tcl, I don't know how to "drive" a text-mode app you can't change (because you don't know its language, whatever it may be) from a GUI front-end -- `expect` is Tcl, `pyexpect` is Python (I don't know of any equivalent for ObjC). However, Python is *easy* to learn!-)
Alex Martelli
THanks! ok, no problem! I'll check that out! :D BTW, where can I find documentation on pyexpect?
Elijah W.
@Elijah, sorry, I meant `pexpect`, http://www.noah.org/wiki/Pexpect
Alex Martelli
Ok, thanks again!
Elijah W.