Problems with xrange Python

0

Hello again everyone,

It turns out that I installed a library to call some functions, but those functions use the xrange function and for some reason Python does not recognize it ...

The error is as follows:

Traceback (most recent call last):
  File "prueba.py", line 85, in <module>
    b = metrikz.pbvif(reference_images[5], reference_images[2]) # PBVIF
  File "/home/lucia/anaconda3/lib/python3.5/site-packages/pymetrikz-
0.4-py3.5.egg/metrikz.py", line 265, in pbvif
    zipped = map(lambda x: __get_num_den_level(ref, dist, x), xrange(1, 5))
NameError: name 'xrange' is not defined

Does it have to do with using Python3.x and not Python2.x?

I hope you can help me.

Thanks again.

Lucia

    
asked by Lucy_in_the_sky_with_diamonds 06.04.2017 в 23:43
source

1 answer

0

You can use a small hack:

try:
    xrange = xrange
except NameError:
    xrange = range

If xrange is present, it will never happen. Otherwise, if there is no xrange in your Python installation, you will have an alias by ordinary range.

    
answered by 07.04.2017 в 21:36