[Tutor] Python printing parentheses and quotes

Sai Allu sai.allu at nutanix.com
Mon Jun 10 12:50:26 EDT 2019


Hello!

I was just wondering if anybody encountered an issue where the Python interpreter was changing how it interprets print statements. So I'm using default Python on Mac OSX (2.7.10 I'm pretty sure) and running with the "python script.py" command.

Basically what happened was that I had a few lines in the script like this
ip = "10.41.17.237"
print("         Welcome to Squid Monitoring for ", ip)
print("")

and the output was like this

("           Welcome to Squid Monitoring for 10.41.17.237")

("")

So it was printing parentheses and quotes. The above result might not be exactly accurate because I didn't save the output, but it was something generally like that.

Then I changed a few small things in the script but nothing big ("import sys", adding "#!usr/bin/env python", and accidentally trying to close the Python interpreter by using ^C multiple times).

I didn't really change too much though but maybe I changed something simple that I didn't know would cause something like that.

Is there any reason why Python would start to print parentheses and quotes like that. Thank you!

Best Wishes,
Sai Allu


P.S. After I upgrade to Python3 this started working. When I kept Python2, then I was able to add an extra statement like Print("Yo") in Sublime Text and this printed Yo just like expected. But actually maybe I had Python3 before I added this print statement, I'm not too sure.


More information about the Tutor mailing list