Only call function if PyMOL running
I have a script that performs some calculations on a protein. When it's finished, a method imports the pymol module, and uses the pymol.cmd API to display results in a PyMOL session. The process is something akin to the following: def display_results(results, protein_fn): import pymol pymol.cmd.load(protein_fn) pymol.cmd.alter(...) ... protein_fn = "1abc.ent" results = analyze_protein(protein_fn) display_results(results, protein_fn) However, my script doesn't necessarily need to display the results in PyMOL, and I'd like this to only be done if PyMOL is installed and running. It's easy to