<- Back | Index | Forward ->
Exceptions
Exceptions indicate that an "exceptional" condition has occured:
- File cannot be opened,
- Input parameters are out of range,
- Object does not have the requested property,
- SMARTS string cannot be parsed,
- Bond cannot be added (eg, dt_mod_is_on == FALSE),
- Canonical SMILES cannot be generated.
Why use them?
- You must explicitly ignore exceptions,
- Limit problems from spreading,
- Out-of-band error messages are hard to check,
- Code can be half the size as similar code with explicit checks.
try:
mol = Smiles.smilin("COO")
atoms = mol.atoms
atoms[0].addbond(atoms[2]) # Won't work; mod is off!
mol.cansmiles()
except DaylightError, msg:
print "Cannot do that:", msg