“run” executes an external Python script in a local name space, the main Python namespace, the global PyMOL namespace, or in its own namespace (as a module).
run file [, namespace ]
file = string: a Python program, typically ending in .py or .pym.
namespace = local, global, module, main, or private
The default mode for run is “global”.
Due to an idiosyncracy in Pickle, you can not pickle objects directly created at the main level in a script run as “module”, (because the pickled object becomes dependent on that module). Workaround: delegate construction to an imported module.