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

Reply via email to