From: Bruce S. <bas...@nc...> - 2010-08-20 18:46:29
|
Good news and bad news about Python 3. To my surprise and pleasure, building VPython for Python 3.1 turned out (with one crucial exception) to be very easy. No changes were necessary in the C++ code; the Boost libraries just work. This is despite the fact that I've seen a document that talks about rather significant changes required to make an extension module written for Python 2 like Visual work with Python 3. I guess that these changes have been taken care of in Boost. For those components of Visual written in Python (for example, primitives.py and graph.py), I ran them through the excellent 2to3 convertor that comes with Python and then made a few minor tweaks. These converted files work without change on Python 2.7, because a lot of work went into letting Python 2.7 handle both old and new syntax. I'm really impressed by the excellent work that has gone into making the 2 -> 3 transition as easy as possible. All the demo programs work except for those that use the new 3D text object (stonehenge, text3D). The problem is that there isn't a Python 3 version of FontTools, and my attempts to make one have failed. As with the Visual .py files, I ran FontTools through the 2to3 convertor, then made some minor adjustments having to do with the fact that in Python 3 there is a clean distinction between strings (Unicode by default) and byte arrays, whereas Python 2 programs (including FontTools) often used strings to hold data. I'm currently stuck in the getTableModule routine in FontTools/fontTools/ttLib/__init__.py. No matter what I try, the __import__ statement always fails, despite the fact that I can read the corresponding file in the same routine, as a test. I'm unable to reproduce this import problem in an isolated test case. So currently I'm stuck. I've been doing this work on Windows; I don't expect things will be different on other platforms. Bruce Sherwood |