printing with print

Timothy R Evans tre17 at pc142.cosc.canterbury.ac.nz
Wed Jun 30 01:10:51 CEST 1999


Angus MacKay <amackay at starvision.com> writes:

> is there any other way to print that with print?
> perhaps with a real function.
> 
> I want to print two things without a space being added between them:
> foo = "there"
> print "hi" + foo
> 
> works fine but: 
> foo = 2
> print "hi" + foo
> 
> does not. I like the printing of any object ability of "print" so I
> do not want to use "" % style printing, I just want to be able to
> govern the whitespace that gets output.
> 
> cheers, Angus.

import string

def print_without_space(*args):
    print string.join(map(str, args), '')


>>> foo = 2
>>> print_without_space('foo', '2', foo)
foo22

This does what you want, but wouldn't the % operator be easier?

--
Tim Evans





More information about the Python-list mailing list