printing something without a newline OR a space after it?

Harry George at
Thu Jun 3 16:12:09 CEST 2004

Alex Hunsley <lard at> writes:

> Very very simple problem here, can't find out how to do it...
> I want to print something without a new line after it, so I can later
> output something right after it on the same line.
> If I do:
>    print "stuff here",
>    print "more"
> .. it doesn't output a newline, but it does output a space:
>    stuff here, more
> .. whereas I want no newline and no space:
>    stuff here,more
> How is this done?
> thanks
> alex

Just "write" to your file.  For stdout (equiv of print), you can use:

def msg(txt):
    sys.stdout.flush()     #to see results immediately

    msg('stuff here,')

If you don't care about flushing, try:
    out('stuff here,')

-- at
6-6M21 BCA CompArch Design Engineering
Phone: (425) 342-0007

More information about the Python-list mailing list