Skip to content

Instantly share code, notes, and snippets.

@fjorgemota
Created October 1, 2011 17:57
Show Gist options
  • Select an option

  • Save fjorgemota/1256415 to your computer and use it in GitHub Desktop.

Select an option

Save fjorgemota/1256415 to your computer and use it in GitHub Desktop.
Iterator Python que permite dar split em uma String progressivamente conforme o decorrer de um Loop
def SplitIterator(s,separator):
s = list(s)
c = 0
l = len(separator)
separator = list(separator)
last_token = []
while s[c:]:
if s[c:c+l] == separator:
a = "".join(last_token)
last_token = []
yield a
else:
last_token.extend(s[c])
c += 1
yield "".join(last_token)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment