Understanding generators in Python

前端 未结 12 1571
日久生厌
日久生厌 2020-11-21 05:46

I am reading the Python cookbook at the moment and am currently looking at generators. I\'m finding it hard to get my head round.

As I come from a Java background, i

12条回答
  •  执念已碎
    2020-11-21 06:20

    I believe the first appearance of iterators and generators were in the Icon programming language, about 20 years ago.

    You may enjoy the Icon overview, which lets you wrap your head around them without concentrating on the syntax (since Icon is a language you probably don't know, and Griswold was explaining the benefits of his language to people coming from other languages).

    After reading just a few paragraphs there, the utility of generators and iterators might become more apparent.

提交回复
热议问题