dumb question.

Ignacio Vazquez-Abrams ignacio at openservices.net
Wed Aug 29 16:11:57 EDT 2001


On Wed, 29 Aug 2001, Adonis Vargas wrote:

> is the behaviour of print suppose to automatically start a new line? or does
> the print command suppose to wait for a cr\lf prior to ending the line?
> because everytime i would like to use the print command to print X line of
> text/numbeers/etc. sequentially it start a new line everytime print is
> issued; isthis a normal thing? or a problem?
>
> Adonis

print automatically ends the printed text with a \n. You can avoid this in two
ways:

1) Print everything you need at once:

---
print '%s, my good friend, I just ate %d hamburgers!' % (name, count)
---

2) Use sys.stdout:

---
sys.stdout.write("This is on a line! ")
sys.stdout.write("This is on the same line!\n")
sys.stdout.write("This is not!\n")
---

-- 
Ignacio Vazquez-Abrams  <ignacio at openservices.net>






More information about the Python-list mailing list