On Apr 13, 2011, at 2:32 PM, Paul Shannon wrote:
>
>>>> filename = 'enzymaticReaction.xml'
>>>> m = readModel (filename) # <libsbml.Model; proxy of <Swig Object of type 'Model_t *' at 0x10062f150> >
>>>> c = m.getListOfCompartments () # <libsbml.ListOfCompartments; proxy of <Swig Object of type 'ListOfCompartments *' at 0x100616fc0> >
>>>> len (c) # 1
>>>> c [0] # Segmentation fault; c.get (0) segfaults also
>
For me this looks like a problem with the SBML Document going out of scope. As context, all SBML objects provided by libsbml live in an SBMLDocument. If that document goes out of scope, all references left to the SBML objects inside become invalid. could you try the following:
from libsbml import *
doc = readSBMLFromFile(filename)
m = doc.getModel()
c = m.getListOfCompartments()
c[0]