printing something without a newline OR a space after it?
Harry George
harry.g.george at boeing.com
Thu Jun 3 10:12:09 EDT 2004
Alex Hunsley <lard at tardis.ed.ac.molar.uk> 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.write(txt)
sys.stdout.flush() #to see results immediately
Thus:
msg('stuff here,')
msg('more\n')
If you don't care about flushing, try:
out=sys.stdout.write
out('stuff here,')
out('more\n')
--
harry.g.george at boeing.com
6-6M21 BCA CompArch Design Engineering
Phone: (425) 342-0007
More information about the Python-list
mailing list