def reiterate(iterable):
 if isinstance(iterable, (list, tuple)):
  return iterable
 else:
  iterator = iter(iterable)
  try:
   chunk = ''
   while (not chunk):
    chunk = next(iterator)
   return CloseableChain([chunk], iterator)
  except StopIteration:
   return []

def reiterate ( iterable ) : if isinstance ( iterable , ( list , tuple ) ) : return iterable else : iterator = iter ( iterable ) try : chunk = '' while ( not chunk ) : chunk = next ( iterator ) return CloseableChain ( [ chunk ] , iterator ) except StopIteration : return [ ]
consume the first item from an iterator .