def _gen_find(subseq, generator):
 subseq = list(subseq)
 pos = 0
 saved = []
 for c in generator:
  saved.append(c)
  if (len(saved) > len(subseq)):
   saved.pop(0)
   pos += 1
  if (saved == subseq):
   return pos
 return (-1)

def _gen_find ( subseq , generator ) : subseq = list ( subseq ) pos = 0 saved = [ ] for c in generator : saved . append ( c ) if ( len ( saved ) > len ( subseq ) ) : saved . pop ( 0 ) pos += 1 if ( saved == subseq ) : return pos return ( - 1 )
returns the first position of subseq in the generator or -1 if there is no such position .