1 2cmd = __import__("sys").modules["pymol.cmd"] 3 4try: 5 basestring 6except NameError: 7 basestring = (str, bytes) 8 9def _raising(code=-1,_self=cmd): 10 # WARNING: internal routine, subject to change 11 return is_error(code) and _self.get_setting_boolean("raise_exceptions") 12 13def is_string(obj): 14 return isinstance(obj, basestring) 15 16def is_list(obj): 17 return isinstance(obj, list) 18 19def is_dict(obj): 20 return isinstance(obj, dict) 21 22def is_tuple(obj): 23 return isinstance(obj, tuple) 24 25def is_sequence(obj): 26 return isinstance(obj, (list, tuple)) 27 28def is_error(result): # errors are always negative numbers 29 if isinstance(result, int): 30 return (result<0) 31 return 0 32 33def is_ok(result): # something other than a negative number 34 return not is_error(result) 35