Simple vtk file reading for meshes:



import xml.etree.ElementTree as ET # Python 2.5
tree = ET.parse("/home/bp/work/patch104.out.1.vtu")
points=tree.getroot().find("UnstructuredGrid/Piece/Points/DataArray")
array = [float(s) for s in points.text.split()]

-------------------------------------------------------------------------
Debugging:
-------------------------------------------------------------------------
How do I debug my Python extensions?

Greg Burley gives the following answer for Unix GCC users:

    Once you have created a boost python extension for your c++ library or class, you may need to debug the code. Afterall this is one of the reasons for wrapping the library in python. An expected side-effect or benefit of using BPL is that debugging should be isolated to the c++ library that is under test, given that python code is minimal and boost::python either works or it doesn't. (ie. While errors can occur when the wrapping method is invalid, most errors are caught by the compiler ;-).

    The basic steps required to initiate a gdb session to debug a c++ library via python are shown here. Note, however that you should start the gdb session in the directory that contains your BPL my_ext.so module.

    (gdb) target exec python
    (gdb) run
     >>> from my_ext import *
     >>> [C-c]
    (gdb) break MyClass::MyBuggyFunction
    (gdb) cont
     >>> pyobj = MyClass()
     >>> pyobj.MyBuggyFunction()
    Breakpoint 1, MyClass::MyBuggyFunction ...
    Current language:  auto; currently c++
    (gdb) do debugging stuff

