We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 794ddd2 commit 6f3d665Copy full SHA for 6f3d665
src/string_builder.py
@@ -15,10 +15,20 @@ def __str__(self):
15
return self.style
16
17
def __add__(self, other):
18
- if not isinstance(other, _ApplyStyle):
+ if not isinstance(other, (str, _ApplyStyle)):
19
raise TypeError
20
- else:
+ elif isinstance(other, _ApplyStyle):
21
return _ApplyStyle(f"{self.style} {other.style}")
22
+ else:
23
+ return _ApplyStyle(f"{self.style} {other}")
24
+
25
+ def __sub__(self, other):
26
27
+ raise TypeError
28
29
+ return _ApplyStyle(self.style.replace(other.style, "").strip())
30
31
+ return _ApplyStyle(self.style.replace(other, "").strip())
32
33
def apply_style(self, *strings):
34
braces = "{}" * len(strings)
0 commit comments