FW: printing

Jaap Vermeulen (jaap@sequent.com)
Thu, 10 Feb 94 15:10:00 PST

Looks like this never made it to the list...

----------
From: Jaap Vermeulen (jaap)
To: python-list-request
Subject: Re: printing
Date: Tuesday, February 08, 1994 2:50PM

| What I want to do is this...
|
| a = '1'
| b = '2'
|
| print a,
| print ',',
| print b
|
| and have it come out as:
|
| 1, 2

That's inconsistent. How is print supposed to know when to use a space and
when not? My solution:

import sys

def myprint(*messages):
# Only write once to improve performance
text = ''
for message in messages:
if type(message) == type(''):
text = text + message
else:
text = text + `message`
sys.stderr.write(text)

a = '1'
b = '2'
myprint(a)
myprint(', ')
myprint(b, '\n')

Or any variant you like.

Good luck,

-Jaap-