next renamed to __next__

nick3499
1 min readNov 28, 2016

--

In Python 3, `iterator.next()` was renamed to `iterator.__next__()` to clearly designate it as a magic method or dunder method, consistent with other protocols.

…PEP [3114] proposes that the next method be renamed to __next__ , consistent with all the other protocols in Python in which a method is implicitly called as part of a language-level protocol, and that a built-in function named next be introduced to invoke __next__ method, consistent with the manner in which other protocols are explicitly invoked.[1]

  1. PEP 3114 — Renaming iterator.next() to iterator.__next__()

--

--

nick3499
nick3499

Written by nick3499

coder of JavaScript and Python

No responses yet