Closed drdhaval2785 closed 4 years ago
The following seems to correct this error.
import string
if sys.version_info[0] == 2:
from string import maketrans
else:
maketrans = ''.maketrans
A trial led to the next following error.
Traceback (most recent call last):
File "extract_keys_b.py", line 69, in <module>
extract_keys_b(filein,fileout)
File "extract_keys_b.py", line 51, in extract_keys_b
key = key.decode("utf-8").encode("ascii","ignore")
AttributeError: 'str' object has no attribute 'decode'
The following corrected this error.
if sys.version_info[0] == 2:
sorted_keys = sorted(keys,cmp=slp_cmp)
else:
sorted_keys = sorted(keys, key=functools.cmp_to_key(slp_cmp))
But a new error crept in.
slp_cmp error: a= b'BUtavinAyaka' b= b'gaRqopaDAna'
@funderburkjim
I may try to make this python2 and python3 compliant. But I am not sure how this code functions.
May I request you to pay personal attention to the code extract_keys_b.py and rewrite it as far as possible making it python2 and python3 compliant.
The main differences are
If you can rewrite the code making it compliant and without using maketrans / sorted behaviour, it will work in both. I am for now not changing it.
It worked well on my python3 local installation after Jim's extensive refactoring. Closing the issue.
While regenerating the local version of MW dictionary, the following error came up.
It seems that the module string behaves differently in python2 and python3.