[Pythonmac-SIG] PyObjC vs "old school" embedding
Bob Ippolito
bob at redivi.com
Tue May 31 22:51:24 CEST 2005
On May 31, 2005, at 1:17 PM, gandreas at gandreas.com wrote:
> So PyOXIDE is based on the traditional way to embed python in an
> application (explicitly calling the python APIs to access and call
> stuff), and this worked reasonably well. For example, it runs
> various scripts at startup, which register various callbacks to
> handle things like new documents, new interactives, etc... (and
> then the underlying Objective C code explicitly calls these
> callbacks at appropriate points).
I would just throw this stuff away and take advantage of what PyObjC
can (and has always been able to) do for you. Digging at the Python
API is hard to get right, and is a LOT more code, as you've shown.
Somewhere in PyOXIDE you're not managing interpreter state correctly,
probably not in the code you've pasted, I don't have time to look
into it... but I HIGHLY RECOMMEND that you throw away all your Python
C API code and use a PyObjC-based bundle instead, which will take
care of managing interpreter state and such for you at message
dispatch boundaries.
> (* - I've downloaded and installed PyObjC 1.3.6 twice but for some
> reason it doesn't want to use it:
>
> gandreas% /Library/Frameworks/Python.framework/Versions/Current/bin/
> python2.4
> Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
> [GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import objc
> >>> objc.__version__
> '1.3.5'
> >>> objc.__file__
> '/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/
> site-packages/PyObjC/objc/__init__.pyc'
> )
Anyone else have this problem?
-bob
More information about the Pythonmac-SIG
mailing list