import re class Border: def __init__(self, top, right, bottom, left, left_all, right_all): self.top = top self.right = right self.bottom = bottom self.left = left self.left_all = left_all self.right_all = right_all def __str__(self): def sym(value, letter): return letter if value else "" T, R, B, L, l, r = self.top, self.right, self.bottom, self.left, self.left_all, self.right_all abbrev = f'{sym(T, "t")}{sym(R, "r")}{sym(B, "b")}{sym(L, "l")}{sym(l, "L")}{sym(R, "R")}' abbrev = re.sub(" ", "", abbrev) if abbrev: abbrev = f"|{abbrev}|" return f'' def has(self): return [self.top, self.right, self.bottom, self.left]