Re: printing

Jaap Vermeulen (jaap@sequent.com)
Tue, 08 Feb 94 14:50:00 PST

| 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-