vendredi 1 juillet 2016

Why does print() print an empty tuple instead of a newline? [on hold]


The error was caused by a typo. Please flag this question as off-topic. I am having a little issue with the following lines. from __future__ import print_function print() If I open up my Windows CLI and run it, it runs as expected. When I stick it in a program and execute it, instead of simply printing a newline, it prints (). Has anybody run into this before? Additional Details: If I run a program with just those two lines, it runs as expected. But for some reason, in my program print() prints (). If I replace that line with print(1), it prints 1 as it should. Running on Windows 8 64-bit. Python 2.7.11 (v2.7.11:6d1b6a68f775) Minimal, complete, and verifiable example: class A: def f(self): print() if __name__ == '__main__': a = A() a.f() Final Update: Oh my!!!! I am an idiot. I have a driver program that has the future import, but the class (which is another file) does not! I do have statements like print('abc', file=sys.stderr), but they were not being executed, so the program ran no problem. My example above actually runs fine. The example I was running didn't have the import. The file I was editing (otherwise an exact copy of the example) did. Woops!!!!

Aucun commentaire:

Enregistrer un commentaire