Skip to Content
Practical Time Series Analysis
book

Practical Time Series Analysis

by PKS Prakash, Avishek Pal
September 2017
Beginner
244 pages
5h 20m
English
Packt Publishing
Content preview from Practical Time Series Analysis

Iterables

Objects that do not have the __iter__ or next function but can be used to create an iterator are iterables. The built-in __iter__ function takes a sequential object as input and returns an iterator. Then, another built-in function, next, takes the iterator and returns the iterator's elements in every invocation. Lists and tuples are not iterators but can be used to create iterators using the next function. The following code snippet demonstrates using a list as an iterator:

mylist = [1,2,3,4]mylist_iter = iter(mylist)print(type(mylist))print(type(mylist_iter))<class 'list'><class 'list_iterator'>

Notice that mylist is of type list while mylist_iter, which is created by the iter function, is of type list_iterator.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Practical Time Series Analysis

Practical Time Series Analysis

Aileen Nielsen

Publisher Resources

ISBN: 9781788290227Supplemental Content