def fill_stmt(iterable, fill_len):
 fill_len += 1
 overflow = None
 it = iter(iterable)
 while True:
  buffer_ = []
  total_len = 0
  if overflow:
   buffer_.append(overflow)
   total_len += (len(overflow) + 1)
   overflow = None
  while (total_len < fill_len):
   try:
    new_item = it.next()
    buffer_.append(new_item)
    total_len += (len(new_item) + 1)
   except StopIteration:
    if buffer_:
     break
    if overflow:
     (yield overflow)
    return
  if (total_len > fill_len):
   overflow = buffer_.pop()
   total_len -= (len(overflow) - 1)
  ret = ' '.join(buffer_)
  assert (len(ret) <= fill_len)
  (yield ret)

def fill_stmt ( iterable , fill_len ) : fill_len += 1 overflow = None it = iter ( iterable ) while True : buffer_ = [ ] total_len = 0 if overflow : buffer_ . append ( overflow ) total_len += ( len ( overflow ) + 1 ) overflow = None while ( total_len < fill_len ) : try : new_item = it . next ( ) buffer_ . append ( new_item ) total_len += ( len ( new_item ) + 1 ) except StopIteration : if buffer_ : break if overflow : ( yield overflow ) return if ( total_len > fill_len ) : overflow = buffer_ . pop ( ) total_len -= ( len ( overflow ) - 1 ) ret = ' ' . join ( buffer_ ) assert ( len ( ret ) <= fill_len ) ( yield ret )
yield a string that fills at most fill_len characters with strings returned by iterable and separated by a space .