0

Simple question.

I have a file called printtest.py in Pythong 3.7.3 that contains one line of code:

print("Test", 1)

The result of importing it is:

Test 1

I then change the file to be printtest.pyx and change nothing else. I compile using Cython 0.29.12. Same single line of code. Now on importing I get:

('Test', 1)

Any time I use the print statement I get the extra parentheses and comma that I don't want. Why does it behave differently?

Bruce Nielson
  • 753
  • 8
  • 23
  • 2
    Maybe related to https://stackoverflow.com/questions/19185338/cython-error-compiling-with-print-function-parameters ? – tomjn Aug 22 '19 at 15:14
  • 4
    looks like it's behaving like python 2 print, rather than python 3 – Matt Ellen Aug 22 '19 at 15:17
  • Crap, you guys might be right. I didn't even know about the language level setting. I'll try that out. – Bruce Nielson Aug 22 '19 at 15:48
  • I tried switching the language level and started getting a new error that is undoubtedly blocking me from truly verifying this: Unicode literals do not support coercion to C types other than Py_UNICODE/Py_UCS4 (for characters) or Py_UNICODE* (for strings). – Bruce Nielson Aug 22 '19 at 15:52
  • However, that probably means you are all correct. – Bruce Nielson Aug 22 '19 at 15:53
  • Okay, confirmed that was the problem. Thanks. – Bruce Nielson Aug 22 '19 at 16:57
  • 1
    If you're having problems with unicode you might want to look at the "3str" language level, which switches to Python 3 mode for everything but strings. – DavidW Aug 22 '19 at 18:33

0 Answers0