print "foo", without a space

Mikael Johansson mikael.johansson at helsinki.xx
Thu Nov 11 09:33:31 EST 1999

Hello All!

Is there another way of getting print to not make a newline than
    print "foo",  ?
This because the comma always produces a space which necessary
isn't that nice, for example:

for i in range (1,30):
    print i,
    if i%10==1 and i<>11: print "st",
    elif i%10==2 and i<>12: print "nd",
    elif i%10==3 and i<>13: print "rd",
    else: print "th",
    print "fish"
Now you would like the "endings" to come right after the number.
There is naturally always some way to get around this, in this
case for example:

for i in range(1,30):
    print `i`+end[max(min(abs(i)%10,4)-1-

OK, this got a bit out of hand, the above looks terrible, does 
anyone see how it could be simplified? At least it's more general
than the above as it can handle the whole range of integers,
including negative ones :-) However it shows that it would be
less obfuscating to have a print statement that could continue
printing on the same line without a space.

If there isn't an easy way for this, I suggest the following:
    print "foo".
So that a dot at the end of the line would mean "no space either".

Appreciating any comments.

Have a nice day,
    Mikael J.
    for e-mail note that the country code for Finland is not xx

More information about the Python-list mailing list