lunes, septiembre 14, 2015

tl;dr: Python 2 vs Python 3

$ cat main.py
print (u"Hello " + b"World!");

$ python2 main.py
Hello World!

$ python3 main.py
Traceback (most recent call ast):
  File "main.py", line 1, in <module>
    print (u"Hello " + b"World!");
TypeError: Can't convert 'bytes' object to str implicitly

2 comentarios:

Thomas Winwood dijo...

Why do you think adding a blob of arbitrary binary data to a wellformed Unicode string should be a wellformed operation?

alejolp dijo...

Thomas: I don't :) I like what what was changed from Py 2 to Py 3.