Is there a way to globally set the print function separator?

Ned Batchelder ned at nedbatchelder.com
Mon Oct 9 12:38:17 EDT 2017


On 10/9/17 12:22 PM, John Black wrote:
> I want sep="" to be the default without having to specify it every time I
> call print.  Is that possible?
>
>

There isn't a way to change the default for print(sep="") globally. 
Generally when you want better control over the output, you use string 
formatting.  Instead of:

     print("X is ", x, " and y is ", y, sep="")

use:

     print("X is {} and y is {}".format(x, y))

If you show us your actual print lines, we can give more concrete advice.

--Ned.



More information about the Python-list mailing list