def Format(): try: while True: for g in range( 5 ): # groups of 5 blocks for b in range( 4 ): # blocks of 4 characters print( (yield), end='' ) # receive from send print( ' ', end='' ) # block separator print() # group separator except GeneratorExit: # destructor if g != 0 | b != 0: # special case print() fmt = Format() next( fmt ) # prime generator for i in range( 41 ): fmt.send( 'a' ); # send to yield # Local Variables: # # tab-width: 4 # # compile-command: "python3.5 Format.py" # # End: #