def substrings(word, from_beginning_only=False):
 w_len = len(word)
 w_len_plus_1 = (w_len + 1)
 i = 0
 while (i < w_len):
  j = (i + 2)
  while (j < w_len_plus_1):
   (yield word[i:j])
   j += 1
  if from_beginning_only:
   return
  i += 1

def substrings ( word , from_beginning_only = False ) : w_len = len ( word ) w_len_plus_1 = ( w_len + 1 ) i = 0 while ( i < w_len ) : j = ( i + 2 ) while ( j < w_len_plus_1 ) : ( yield word [ i : j ] ) j += 1 if from_beginning_only : return i += 1
a generator of all substrings in word greater than 1 character in length .