Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- class supresser(object):
- def __init__(self, *types):
- self.types = types
- def __enter__(self):
- pass
- def __exit__(self, *args):
- if args[0] in self.types:
- return True
- else:
- return False
- class retyper(object):
- def __init__(self, type_from, type_to):
- self.type_from = type_from
- self.type_to = type_to
- def __enter__(self):
- pass
- def __exit__(self, *args):
- if args[0] == self.type_from:
- exc = self.type_to()
- exc.args = args[1].args
- # print(exc.args == ('lalala', 1))
- raise exc.with_traceback(args[2])
- class dumper(object):
- def __init__(self, stream):
- self.stream = stream
- def __enter__(self):
- pass
- def __exit__(self, *args):
- string = repr(args[0].__name__)[1:-1] + ': ' + str(args[1]) + '\n'
- self.stream.write(string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement