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

  • Thread starter ÖܼÃÊÇĸÀÏÊó
  • Start date
Ö

ÖܼÃÊÇĸÀÏÊó

Any ideas?

Code 1:

from __future__ import print_function, unicode_literals
import sys
print(type('HELLO, WORLD!'), file=sys.stderr)

Result 1:

<type 'str'>

Code 2:

from __future__ import unicode_literals, print_function
import sys
print(type('HELLO, WORLD!'), file=sys.stderr)

Result 2:

File "tmp.py", line 3
print(type(''), file=sys.stderr)
^
SyntaxError: invalid syntax

Code 3:

from __future__ import unicode_literals, print_function
import sys
print >> sys.stderr, type('HELLO, WORLD!')

Result 3:

<type 'unicode'>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top