I'm trying to find the distances between residues of a protein in pymol using a python script, which calls the pymol command cmd.get_distance. However, sometimes there are multiple atom assignments, which causes an error:
GetDistance-Error: Selection 2 doesn't contain a single atom/vertex.
I want to skip over sites that have this problem so I'm trying to use try/pass:
try:
cmd.get_distance(atom2)
except GetDistance-Error:
pass
However, it tells me that there is no such error message:
NameError: global name 'GetDistance' is not defined.
How do I tell it to pass this error? isn't GetDistance-Error the error?
my attempt :
output:
Note that :
printing depends on
cmd.feedback( "disable" , "all" , "errors")
being coomented/uncommented out.trying redirect both stdout and stderr with
from contextlib import redirect_stdout, redirect_stderr
won't result in same effect ofcmd.feedback( "disable" , "all" , "errors")
being uncommented out; possibly because of:see: https://docs.python.org/3/library/contextlib.html#contextlib.redirect_stdout
I believe somehow
CmdException
are not loaded at least forget_distance
command