def head_tail(line):
 generator = (t.strip() for t in line.split(None, 1))
 head = next(generator).strip()
 tail = ''
 try:
  tail = next(generator).strip()
 except StopIteration:
  pass
 return (head, tail)

def head_tail ( line ) : generator = ( t . strip ( ) for t in line . split ( None , 1 ) ) head = next ( generator ) . strip ( ) tail = '' try : tail = next ( generator ) . strip ( ) except StopIteration : pass return ( head , tail )
returns the first word in line and the rest of line or none if the line is too short .