Python iterable and list, dictionary differences and connections

Source: Internet
Author: User
Tags iterable

1 Why are the parameters of some functions specified to Iterable object, but can also pass in list as parameter?

Because list, dictionary are all iterable object.

adding ITER () to the Iterable object will return a iterator.

2 iterable The difference between object and iterator

Iterator can use next () to traverse the access.

Iterable can be traversed with a for.

The for traversal is done by first iterable the iterator object and then using next.

For can traverse the Iterable object directly, or you can traverse the iterator object directly.

Python iterable and list, dictionary differences and connections

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.