yield statement .. by example
السلام عليكم و رحمة الله وبركاته
ده تمرين بسيط علىyield statement
def simpleGenerator( anyList ): for item in anyList: yield item myList = ['Ahmed', 'AlSayed', 'AbdulHameed', 'Osama', 'Gamal'] nameGenerator = simpleGenerator( myList ) for name in myItemsList: print name print myItemsList.next() print myItemsList.next() print myItemsList.next()
وده بس عشان البلوج كان عشش فيه العنكبوت ..

Is there a difference between both examples?
Mahmoud
5 Jul 10 at 2:55 AM
No, I’m just showing that the for construct will be calling the next() method on the returned generator each iteration..
It’s like range() and xrange()..
me
5 Jul 10 at 8:32 AM