Python study day2 Cont.-3

Source: Internet
Author: User

First, the iterator for the python  list of  for  cycle, his internal principle: to see if the next element exists, if present, then take out, if not present, the exception is reported  stopiteration. (Python internal to exception handled) Class listiterator (object)  |  Methods defined here: |    |  __getattribute__ (...)  |      x.__getattribute__ (' name ')  <==> x.name |    |  __iter__ (...) &NBSP;|&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;X.__ITER__ ()  <==> iter (x)  |   |   __length_hint__ (...)  |      private method returning an estimate of  len (list (it)).  |   |  next (...)  |      x.next ()  -> the next value, or  Raise stopiterationlistiterator two, generator range is not generator   and  xrange  is generator readlines not generator   and   The xreadlines  is the generator >>> print range (ten) [0, 1,  2, 3, 4, 5, 6, 7, 8, 9]>>> print xrange (Ten) xrange (10) The generator is created internally based on yield, i.e., created only when used by the generator, thus avoiding memory waste as in the following table:    [13, 22, 6, 99,  11]  please follow the rules to calculate:13  and  22  comparisons, place large values on the right, i.e.:[13, 22, 6, 99, 11]22  and   6  compares large values on the right side, i.e.:[13, 6, 22, 99, 11]22  and  99 , placing large values on the right side, that is: [13, 6,  22, 99, 11]99  and  42  compare large values on the right, i.e.:[13, 6, 22, 11, 99,]  13  and  6  compare large values on the right side, i.e.: [6, 13, 22, 11, 99,]



Python study day2 Cont.-3

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.