Beginner python 3 unicode question

Laszlo Nagy gandalf at shopzeus.com
Sat Nov 16 14:12:50 EST 2013


Example interactive:

$ python3
Python 3.3.1 (default, Sep 25 2013, 19:29:01)
[GCC 4.7.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> import uuid
 >>> import base64
 >>> base64.b32encode(uuid.uuid1().bytes)[:-6].lower()
b'zsz653co6ii6hgjejqhw42ncgy'
 >>>

But when I put the same thing into a source file I get this:

Traceback (most recent call last):
   File "/home/gandalf/Python/Lib/shopzeus/yaaf/ui/widget.py", line 94, 
in __init__
     self.eid = uniqueid()
   File "/home/gandalf/Python/Lib/shopzeus/yaaf/ui/__init__.py", line 
34, in uniqueid
     base64.b32encode(uuid.uuid1().bytes)[:-6].lower()
TypeError: Can't convert 'bytes' object to str implicitly


Why it is behaving differently on the command line? What should I do to 
fix this?


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the Python-list mailing list