NameError: global name 'unicode' is not defined - in Python 3 -


i trying use python package called bidi. in module in package (algorithm.py) there lines give me error, although part of package.

here lines:

# utf-8 ? need unicode if isinstance(unicode_or_str, unicode):     text = unicode_or_str     decoded = false else:     text = unicode_or_str.decode(encoding)     decoded = true 

and here error message:

traceback (most recent call last):   file "<pyshell#25>", line 1, in <module>     bidi_text = get_display(reshaped_text)   file "c:\python33\lib\site-packages\python_bidi-0.3.4-py3.3.egg\bidi\algorithm.py",   line 602, in get_display     if isinstance(unicode_or_str, unicode): nameerror: global name 'unicode' not defined 

how should re-write part of code works in python3? if have used bidi package python 3 please let me know if have found similar problems or not. appreciate help.

python 3 renamed unicode type str, old str type has been replaced bytes.

if isinstance(unicode_or_str, str):     text = unicode_or_str     decoded = false else:     text = unicode_or_str.decode(encoding)     decoded = true 

you may want read python 3 porting howto more such details. there lennart regebro's porting python 3: in-depth guide, free online.

last not least, try use 2to3 tool see how translates code you.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -