The code is as follows:
#!/usr/bin/env Python3#-*-coding:utf-8-*-__author__='life into the play'defUse (name):Print("%s started picking up crap ... "%name) whileTrue:res=yield Print("%s picked up the%s crap"%(name,res))defProduct (Name_mon): Mon=Use (Name_mon) Mon.__next__() forIinchRange (10): Print("son's got another piece of crap.") I+=1mon.send (i) Product ("mom")
This is called the co-process, also called micro-threading.
The results of the operation are as follows:
Mom's starting to pick up the crap. Son again pulled a excrement mother picked up 1 excrement son and pulled a excrement mother picked up 2 excrement son and pulled a excrement mother picked up 3 excrement son and pulled a excrement mother picked up 4 excrement son and pulled a excrement mother picked up 5 excrement son and pulled a excrement mother picked up 6 excrement son and pulled a excrement mother picked up 7 excrement son and pulled a excrement mother picked up 8 excrement son Son and pull a piece of excrement mother picked up 9 of excrement, and pulled a crap mother picked up 10 pieces of excrement
Python Builder main usage