- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/concurrency/examples/Format.py
ra573c22 r2e041e27 4 4 for g in range( 5 ): # groups of 5 blocks 5 5 for b in range( 4 ): # blocks of 4 characters 6 while True: 7 ch = (yield) # receive from send 8 if '\n' not in ch: 9 break 10 print( ch, end='' ) # receive from send 6 print( (yield), end='' ) # receive from send 11 7 print( ' ', end='' ) # block separator 12 8 print() # group separator … … 15 11 print() 16 12 17 input = "abcdefghijklmnop\nqrstuvwx\nyzxxxxxxxxxxxxxx\n"18 19 13 fmt = Format() 20 14 next( fmt ) # prime generator 21 for i in input:22 fmt.send( i); # send to yield15 for i in range( 41 ): 16 fmt.send( 'a' ); # send to yield 23 17 24 18 # Local Variables: # 25 19 # tab-width: 4 # 26 # compile-command: "python3. 7Format.py" #20 # compile-command: "python3.5 Format.py" # 27 21 # End: #
Note:
See TracChangeset
for help on using the changeset viewer.