You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ python-modernize test_py2.py
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
RefactoringTool: No changes to test_py2.py
RefactoringTool: Files that need to be modified:
RefactoringTool: test_py2.py
$ python3 test_py2.py
Traceback (most recent call last):
File "test_py2.py", line 19, in<module>foriin Foo(10):
TypeError: iter() returned non-iterator of type'Foo'
I'm not sure you can always just add six.Iterator to the inheritance list. At least one special case is when the class inherits from object, e.g., Foo(object,Iterator) results in the exception
Classes that implement an iterator have to provide a
next
method in Python 2 but a__next__
method in Python 3. Seehttps://www.python.org/dev/peps/pep-3114/
The six package includes the class
six.Iterator
which you can subclass and provide only a__next__
method.The text was updated successfully, but these errors were encountered: