lunes, septiembre 14, 2015

tl;dr: Python 2 vs Python 3

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

$ python2
Hello World!

$ python3
Traceback (most recent call ast):
  File "", 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.