| t | class SubString(__import__('collections').UserString): | t | class SubString(__import__('collections').UserString): |
| | | |
| def __sub__(self, other): | | def __sub__(self, other): |
| if not isinstance(other, (str, SubString)): | | if not isinstance(other, (str, SubString)): |
| return NotImplemented | | return NotImplemented |
| Counter = __import__('collections').Counter | | Counter = __import__('collections').Counter |
| counter = Counter(other) | | counter = Counter(other) |
| result_chars = [] | | result_chars = [] |
| for ch in self.data: | | for ch in self.data: |
| if counter[ch] > 0: | | if counter[ch] > 0: |
| counter[ch] -= 1 | | counter[ch] -= 1 |
| else: | | else: |
| result_chars.append(ch) | | result_chars.append(ch) |
| return SubString(''.join(result_chars)) | | return SubString(''.join(result_chars)) |