[Tutor] Why does print add spaces ?

Don Arnold Don Arnold" <darnold02@sprynet.com
Sun Mar 16 14:34:02 2003


----- Original Message -----
From: "Tony Cappellini" <tony@tcapp.com>
To: "Don Arnold" <darnold02@sprynet.com>
Sent: Sunday, March 16, 2003 1:46 AM
Subject: Re: [Tutor] Why does print add spaces ?


>
> > >
> > >
> > > In this example
> > >
> > >
> > > mystr="abcdefghi"
> > >
> > > for x in range(1,len(mystr)):
> > >     print "%s," % mystr[x],
> > >
> > >
> > > a, b, c, d, e, f, g, h, i,
> > >
> > > why does print add an implied space ??
> >
> > >>I can't really answer as to the 'why', since it seems like a language
> > design
> > >>issue. Like it or not, that's how the print command behaves.
>
> I should have asked "How are we supposed to know when print will add a
> space or not" ?
> I've used it many times, when it does not add the extra space.
>

I'm pretty sure that without messing around with stdout's softspace
attribute, print always puts a space between comma-separated arguments. But
then again, I'm pretty much a Python newbie, myself. Can you give an example
where the space isn't inserted?

Thanks,
Don