Why does way_1() obtain the correct list but way_2() gets an empty list?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Feb 13 04:47:03 CET 2009


En Thu, 12 Feb 2009 07:07:53 -0200, WP  
<no.i.dont at want.mail.from.spammers.com> escribió:

> Hello group! This is probably a silly newbie mistake but consider the  
> following program:
>
> import libsbml
>
> def getSBMLModel(biomodel_path):
>      reader = libsbml.SBMLReader()
>
>      sbml_doc = reader.readSBML(biomodel_path)
>      sbml_model = None
>
>      if sbml_doc.getNumErrors() > 0:
>          print 'I couldn\'t read the file %s!' % biomodel_path
>          return None
>      else:
>          sbml_model = sbml_doc.getModel()
>
>      return sbml_doc.getModel() # None if file couldn't be opened

Note that sbml_doc.getModel() is called *twice*, the first one is  
discarded. Probably you want to replace the last line with: return  
sbml_model

-- 
Gabriel Genellina




More information about the Python-list mailing list