פייתון/פייתון גרסה 3/רשימת פונקציות מערכת built-in: הבדלים בין גרסאות בדף
תוכן שנמחק תוכן שנוסף
Mathreturn (שיחה | תרומות) אין תקציר עריכה |
Mathreturn (שיחה | תרומות) אין תקציר עריכה |
||
שורה 941:
</source>
|-
|[[פייתון/פייתון גרסה 3/גנרטור#פונקצית next|פונקצית next]]
|גנרטור
|פונקצית next מחזירה את ערך האיטרטור הנוכחי ובכל קריאה מקדמת את המצביע לאיבר הבא באיטרטור
|<source lang = "python">
def hello_world_generator():
yield "hello"
yield "world"
>>>print(next(calling_hello_world_fun))
hello
>>>print(next(calling_hello_world_fun))
world
>>>print(next(calling_hello_world_fun))
Traceback (most recent call last):
File "C:calling_hello_world.py", line 9, in <module> print(next(calling_hello_world_fun))
StopIteration
</source>
|