structure opened this issue on Jun 27, 2019 ยท 94 posts
adp001 posted Wed, 03 November 2021 at 4:01 PM
class ignore_error(object):
def __init__(self, *args):
self.tolerable = args
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
return exc_type in self.tolerable if len(self.tolerable) else True
with ignore_error(NameError, poser.error):
actor = poser.Scene().Actor("not existing actor")
Made a mistake in:
def __exit__(self, exc_type, exc_val, exc_tb):
return exc_type in self.tolerable if len(self.tolerable) else True
the default result must be False, not True:
def __exit__(self, exc_type, exc_val, exc_tb):
return exc_type in self.tolerable if len(self.tolerable) else False