Actually I'm pretty sure what happened was that the "#! usr/bin/python" was in a module that was being imported. So the Python interpreter cached it or somehow crashed randomly, which meant that the print was working as a keyword instead of a function.
But when I removed that "#! usr/bin/python" line and then rewrote the print statements, it went back to working normally. Thank you for the help though! Sai Allu ________________________________ From: Sai Allu Sent: Monday, June 10, 2019 11:53 AM To: Mats Wichmann; tutor@python.org; Deepak Dixit Subject: Re: [Tutor] Python printing parentheses and quotes But then how come it was working earlier for me without that import statement. Python doesn't interpret it as a statement exclusively, before it worked fine as a function. Best Wishes, Sai Allu ________________________________ From: Mats Wichmann <m...@wichmann.us> Sent: Monday, June 10, 2019 11:12 AM To: Sai Allu; tutor@python.org Subject: Re: [Tutor] Python printing parentheses and quotes On 6/10/19 10:50 AM, Sai Allu wrote: > 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. In Python 2, print is a statement. In Python 3 it's a function and behaves like you're expecting. However, the behavior you're seeing is odd (printing parentheses is a surprise unless there's more going on than you've listed) If you want them consistent across both versions, add a statement at the very top: from __future__ import print_function _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor