dumb question.
Jeff Shannon
jeff at ccvcorp.com
Wed Aug 29 17:16:29 EDT 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
This is normal. Actually, it's not that each print *starts* on a new line, it's
that each print statement *ends* by adding a newline on the end. This behavior
can be suppressed, though, by adding a comma at the end.
>>> def ShowList(mylist):
... for item in list:
... print item,
...
>>> ShowList( range(5) )
0 1 2 3 4
>>>
Note that print also does odd things with adding spaces between items printed.
If this is not the desired behavior, it's a good idea to use sys.write()
instead.
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-list
mailing list