Why did Python 2.6 add a global next() function?

后端 未结 3 1064
难免孤独
难免孤独 2020-12-17 16:07

I noticed that Python2.6 added a next() to it\'s list of global functions.

next(iterator[, default])

Retrieve the next item from the i         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-17 16:24

    It's just for consistency with functions like len(). I believe next(i) calls i.__next__() internally.

    See http://www.python.org/dev/peps/pep-3114/

提交回复
热议问题