yunxiaoshi / Neural-IMage-Assessment

A PyTorch Implementation of Neural IMage Assessment
Other
508 stars 92 forks source link

xrange() was removed in Python 3 #1

Closed cclauss closed 6 years ago

cclauss commented 6 years ago

Flake8 testing of https://github.com/kentsyx/Neural-IMage-Assessment on Python 3.6.4

$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

./model.py:40:14: F821 undefined name 'xrange'
    for i in xrange(1, length + 1):
             ^
./model.py:57:14: F821 undefined name 'xrange'
    for i in xrange(mini_batch_size):
             ^
2     F821 undefined name 'xrange'
2
yunxiaoshi commented 6 years ago

@cclauss Yes I am aware, the code is written in Python 2. You can add

from six.moves import xrange

in the import statements to make this error message disappear, or you can just replace xrange with range since in Python 3 range is implemented the same as xrange in Python 2.