-1

in the code snippet below the Pycharm ide says:

def hexdump(src, length=16):
    result = []
    if not isinstance(src, unicode):
        digits = 2
    else:
        digits = 4
    for i in xrange(0, len(src), length):
        s = src[i:i+length]
        hexa = b' '.join(["%0*X" % (digits, ord(x)) for x in s])
        text = b''.join([x if 0x20 <= ord(x) < 0x7F else b'.' for x in s])
        result.append( b"%04X   %-*s   %s" % (i, length*(digits + 1), hexa, text))
unresolved reference 'unicode'
unresolved reference 'xrange'

why or where I can find the relevant documentation?

wjandrea
  • 28,235
  • 9
  • 60
  • 81
jdftwrth
  • 45
  • 5
  • eyllanesc, pardon my lack of understanding these high level languages, but what in tarnation is deprecated and where is a good place to read up on it? – jdftwrth Mar 20 '21 at 18:43
  • 1
    You're trying to run python 2 code in python 3 – Chris_Rands Mar 20 '21 at 18:47
  • 2
    @eyllanesc They're not just deprecated, they're completed removed – Chris_Rands Mar 20 '21 at 18:49
  • 1
    Documentation: [What’s New in Python 3.0](https://docs.python.org/3.0/whatsnew/3.0.html) § [Views and Iterators Instead of Lists](https://docs.python.org/3.0/whatsnew/3.0.html#views-and-iterators-instead-of-lists) (explains `range()` vs `xrange()`) and § [Text vs. Data Instead of Unicode vs. 8-bit](https://docs.python.org/3.0/whatsnew/3.0.html#text-vs-data-instead-of-unicode-vs-8-bit) (explains the sea change in the string-like types - doesn't explicitly say that `unicode` was removed, but it's implied.) – wjandrea Mar 20 '21 at 18:56

1 Answers1

0

use range() instead of xrange(). python3 not support xrange().
if you want more advanced functionality then use numpy.arange()