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

John Black jblack at nopam.com
Tue Oct 10 00:05:33 EDT 2017


In article <mailman.59.1507585675.12137.python-list at python.org>, 
eryksun at gmail.com says...
> 
> On Mon, Oct 9, 2017 at 10:04 PM, John Black <jblack at nopam.com> wrote:
> > In article <org8pq$fgm$1 at gioia.aioe.org>, python at example.invalid says...
> >>
> >> Le 09/10/2017 à 18:22, John Black a écrit :
> >> > I want sep="" to be the default without having to specify it every time I
> >> > call print.  Is that possible?
> >>
> >>  >>> oldprint = print
> >>  >>> def print(*args,**kwargs):
> >> ...   oldprint(*args,**kwargs,sep='')
> >> ...
> >>  >>> print(1,2,3)
> >> 123
> >
> > Winner!  Thanks all.
> 
> functools.partial(print, sep='') is the winner, IMO.

Ok, I got that working too after someone told me I have to import 
functools.  Can you explain what it means?  It looks like it is not 
defining another function like the other solutions but is truly changing 
the defaults for the existing function print?

John Black




More information about the Python-list mailing list