What does it mean to “consume” in Python? In an iterator?

前端 未结 6 731
既然无缘
既然无缘 2020-12-11 01:45

I have been working in Python for a few months now, and it has occurred to me that I often overlook vocabulary that escapes me at first glance, instead trying to get the gis

6条回答
  •  萌比男神i
    2020-12-11 02:17

    I'm not a Python expert, but I can say this: Most of the time, consumption in programming is the opposite of production. You can classify some processes as producers, which create values; and others as consumers, which use the values created by the producers.

    In the case of an iterator, an iterator is a producer which goes through an iterable object and "produces" each value, one at a time, in order. To "consume" data from an iterator simply means to use it.

提交回复
热议问题