Return True if self sequence is contiguous with other span without overlap. For example: >>> Span([5, 7]).touch(Span([5])) False >>> Span([5, 7]).touch(Span([5, 8])) False >>> Span([5, 7]).touch(Span([7, 8])) False >>> Span([5
(self, other)
| 382 | return self.start > other.end |
| 383 | |
| 384 | def touch(self, other): |
| 385 | """ |
| 386 | Return True if self sequence is contiguous with other span without overlap. |
| 387 | |
| 388 | For example: |
| 389 | >>> Span([5, 7]).touch(Span([5])) |
| 390 | False |
| 391 | >>> Span([5, 7]).touch(Span([5, 8])) |
| 392 | False |
| 393 | >>> Span([5, 7]).touch(Span([7, 8])) |
| 394 | False |
| 395 | >>> Span([5, 7]).touch(Span([8, 9])) |
| 396 | True |
| 397 | >>> Span([8, 9]).touch(Span([5, 7])) |
| 398 | True |
| 399 | """ |
| 400 | return self.start == other.end + 1 or self.end == other.start - 1 |
| 401 | |
| 402 | def distance_to(self, other): |
| 403 | """ |