python_xid
python_xid copied to clipboard
TypeError: 'map' object is not subscriptable
I've simply install xid using command pip install xid
then created a simple file to check if it's working fine or not.
first.py
from xid import Xid
guid = Xid()
print(guid.string())
and then run it as below, but could not run and getting the exception as below.
root@f0b2d7f8a449:/demo# python first.py
Traceback (most recent call last):
File "first.py", line 2, in <module>
guid = Xid()
File "/usr/local/lib/python3.8/site-packages/xid.py", line 92, in __init__
id = generate_new_xid()
File "/usr/local/lib/python3.8/site-packages/xid.py", line 71, in generate_new_xid
id[4] = machineID[0]
TypeError: 'map' object is not subscriptable
root@f0b2d7f8a449:/demo#
If any one can check and help me to fix this issue would be great. tx.
Sorry, I used Python3.6.8, I also get map error in my project, maybe this package doesn't support Py3 very well ?
This is an issue related to Python3. It seems to stem from some differences in how map()
behaves in Python3, for example, I was able to make some progress getting the code working by replacing map(ord, buf)
with [i for i in buf]
... though it does look like the version here in GitHub uses list(map(ord, buf))
In any event, I gave up trying to get a patch working and ended up using this instead: https://github.com/alexferl/xid
This is fixed in 1.0.5 here on GitHub, but the version in pypi (1.0.4) still has the issue.
please publish 1.0.5 on pypi