What a weird thing !!?
Florent Ramière
framiere at netcom-service.com
Sat Feb 19 06:19:23 EST 2000
Hi,
sorry for replying this message, but is what you say means that there is
absolutely no way to print excatly what i want to print ???
I will never be able to display "ab" in two print ???
That make me nervous about python !
Florent.
Michael Hudson <mwh21 at cam.ac.uk> wrote in message
news:m3u2j5zidf.fsf at atrus.jesus.cam.ac.uk...
> "Florent Ramière" <framiere at netcom-service.com> writes:
>
> > Thanks for your answers,
> >
> > in fact as Moshe Zadka told me, it is a documented feature ...
(sorry)
> > Well, i should have read more carefully the doc (re-sorry)
> > And is there a solution to my problem ?
> > And sys.stdout.write is not a good solution for me (i need to keep
> > printing with print)
> >
> > Is there an easy way to override the print statement (i saw it one
time
> > in the news, but i can not find it)
> >
>
> You want sys.stdout.softspace:
>
> >>> print 1,;print 2
> 1 2
> >>> print 1,;sys.stdout.softspace=0;print 2
> 12
>
> It's a bit tedious to actually use, as it keeps getting reset; you
> could try this:
>
> >>> class SF:
> ... def __init__(self,string): self.string = string
> ... def __str__(self): sys.stdout.softspace = 0; return self.string
> ...
> >>> print SF("2"),1
> 21
>
> HTH,
> Michael
More information about the Python-list
mailing list