Python Forum
difference between next() and .__next__
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
difference between next() and .__next__
#4
__next__ is a special method.
https://docs.python.org/3/library/stdtyp...r.__next__
https://docs.python.org/3/reference/expr...r.__next__

next() is a built-in function, that calls __next__() method of the first argument you supply. The docs:

Quote:next(iterator)
next(iterator, default)

Retrieve the next item from the iterator by calling its __next__() method. If default is given, it is returned if the iterator is exhausted, otherwise StopIteration is raised.
akbarza likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: difference between next() and .__next__ - by buran - Oct-13-2023, 07:42 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020