Again: Please hear my plea: print without softspace
Stephen Horne
steve at ninereeds.fsnet.co.uk
Thu Mar 4 17:43:41 EST 2004
On Thu, 04 Mar 2004 13:58:32 -0500, mwilson at the-wire.com (Mel Wilson)
wrote:
>In article <f0oe40hujm0rqcci2fgrhc445qgjs9anfe at 4ax.com>,
>David MacQuigg <dmq at gain.com> wrote:
>>What I think is going on "under the hood" with the print statement is:
>>
>>def print(*args):
>> for arg in args:
>> sys.stdout.write(arg)
> ^^^
>Ahem, (str(arg))
>
>> sys.stdout.write(' ')
Ahem part two - too many spaces, as you add one after the last arg.
def print (*args) :
for arg in args[:-1] :
sys.stdout.write (str (arg))
sys.stdout.write (" ")
if len(args) > 0 :
sys.stdout.write (str (args [-1]))
sys.stdout.write ("\n")
...or...
def print (*args) :
sys.stdout.write (string.join ([str(i) for i in args], " ") + "\n")
--
Steve Horne
steve at ninereeds dot fsnet dot co dot uk
More information about the Python-list
mailing list