Skip to content

Instantly share code, notes, and snippets.

@spitz-dan-l
Last active August 29, 2015 14:02
Show Gist options
  • Save spitz-dan-l/f2bddaaae96daf80189b to your computer and use it in GitHub Desktop.
Save spitz-dan-l/f2bddaaae96daf80189b to your computer and use it in GitHub Desktop.
def remove_spans_gen(s, spans):
checker = make_range_checker(spans); next(checker)
return ''.join(c for (i, c) in enumerate(s) if not checker.send(i))
def make_range_checker(spans):
idx = yield
for (i, j) in spans:
while idx < j:
idx = (yield i <= idx < j)
while True:
yield False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment