Python's iterators

Publicado el: 15 septiembre 2017
en el canal de: Edik Mkoyan
811
2

Iterators are objects that can be iterated upon. In this tutorial, you will learn how iterator works and how you can build your own iterator using _iter_ and _next_ methods.
Python Iterators

Iterators are everywhere in Python. They are elegantly implemented within for loops, comprehensions, generators etc. but hidden in plain sight.

Iterator in Python is simply an object that can be iterated upon. An object which will return data, one element at a time.

Technically speaking, Python iterator object must implement two special methods, __iter__() and __next__(), collectively called the iterator protocol.

An object is called iterable if we can get an iterator from it. Most of built-in containers in Python like: list, tuple, string etc. are iterables.

The iter() function (which in turn calls the __iter__() method) returns an iterator from them.


En esta página del sitio puede ver el video en línea Python's iterators de Duración hora minuto segunda en buena calidad , que subió el usuario Edik Mkoyan 15 septiembre 2017, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 811 veces y le gustó 2 a los espectadores. Disfruta viendo!