Iterators are widely used in Python. They let us traverse various “containers” without having to use a conventional for loop, as is common in other programming languages. These so-called containers are not limited to lists—dictionaries, strings, and ranges can all be iterated over in a similar way. In this chapter, we’ll explore how iterators are implemented.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

How Iterators Work Internally

  • Chien-Lung Kao

摘要

Iterators are widely used in Python. They let us traverse various “containers” without having to use a conventional for loop, as is common in other programming languages. These so-called containers are not limited to lists—dictionaries, strings, and ranges can all be iterated over in a similar way. In this chapter, we’ll explore how iterators are implemented.