[Python-porting] Questions for porting unicode with backward compatibility

Tim Golden mail at timgolden.me.uk
Tue May 21 10:52:52 CEST 2013


On 21/05/2013 09:46, Lennart Regebro wrote:
> On Tue, May 21, 2013 at 10:32 AM, Chitrank Dixit
>> 3) does next() method behavior is same in both python 2.7 and python 3.3.
> 
> As far as I know, yes.

Since you mention the next() *method*: in Python 3, the iterator
protocol changed slightly. Previously, the protocol demanded that a
Python iterator have a .next() method which was invoked by the protocol
or by the next() builtin function. In Python 3, the iterator has a
.__next__() method instead. Otherwise, the protocol works as before:
"for x in iterable:" works as expected, and the next() builtin invokes
".__next__()" rather than ".next()"

TJG



More information about the Python-porting mailing list