Created
May 28, 2020 20:02
-
-
Save ZhouYang1993/2e1e24476d82ab984cd4bf3364ccdbaa to your computer and use it in GitHub Desktop.
Iterators in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections.abc import Iterable, Iterator | |
| my_list = [1, 2, 3, 4, 5] | |
| my_list_iterator = iter(my_list) | |
| isinstance(my_list,Iterable) | |
| #True | |
| isinstance(my_list,Iterator) | |
| #False | |
| isinstance(my_list_iterator,Iterable) | |
| #True | |
| isinstance(my_list_iterator,Iterator) | |
| #True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment