Teaching the "range" function in Python 3
Chris Angelico
rosuav at gmail.com
Fri Jun 30 12:27:57 EDT 2017
On Sat, Jul 1, 2017 at 2:17 AM, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> However, to my defense, I must say that in this post my intend
> was to demonstrate what is happening /behind the curtains/ when
> the »for« loop is running, so in this special case, it might be
> appropriate to use a function that otherwise should only be
> called by the Python interpreter. (But I don't actually know
> whether the »for« loop uses »__iter__« or »iter« or some other
> means.)
It basically uses iter().
https://docs.python.org/3/c-api/object.html#c.PyObject_GetIter
"""This is equivalent to the Python expression iter(o)."""
ChrisA
More information about the Python-list
mailing list