[Python 2.6] print_function and unicode_literals cannot be used at the same time?

Christian Heimes lists at cheimes.de
Sun Oct 26 10:13:08 EDT 2008


?????? wrote:
> Any ideas?
> 
> Code 1:
> 
> from __future__ import print_function, unicode_literals
> import sys
> print(type('HELLO, WORLD!'), file=sys.stderr)

You have to do each future import in a separate line:

 >>> from __future__ import unicode_literals
 >>> from __future__ import print_function
 >>> print(type(""), file=sys.stderr)
<type 'unicode'>

Christian




More information about the Python-list mailing list