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

Peter Otten __peter__ at web.de
Mon Oct 9 12:44:59 EDT 2017


John Black wrote:

> I want sep="" to be the default without having to specify it every time I
> call print.  Is that possible?

No, but you can replace the print function with your own:

>>> print = functools.partial(print, sep="")
>>> print("I", "recommend", "you", "choose", "another", "name", "and", 
"preserve", "your", "sanity")
Irecommendyouchooseanothernameandpreserveyoursanity

And everybody else's.




More information about the Python-list mailing list