[Tutor] Printing
Pete Versteegen
pversteegen@gcnetmail.net
Fri Feb 14 18:08:15 2003
Thanks Jeff,
I also found just now that I can do it as follows:
>>> import string
>>> x=['h','e','l','l','o']
>>> text = string.join(x,"")
>>> print text
hello
On 2/14/03 5:19 PM, "Jeff Shannon" <jeff@ccvcorp.com> wrote:
>
> Pete Versteegen wrote:
>
>> Hi pythonians,
>>
>> I'm wrestling with a formatting issue:
>>
>>>>> x=['h','e','l','l','o']
>>>>> for i in range(0, len(x)):
>>>>>
>>>>>
>> ... print x[i],
>> ...
>> h e l l o
>>
>>
>
> If you need more fine-grained control of output than you can get from
> print, then use sys.stdout.write().
>
>>>> import sys
>>>> for x in ['h', 'e', 'l', 'l', 'o']:
> ... sys.stdout.write(x)
> ...
> hello
>>>>
>
> Where print does a variety of convenient formatting tricks that make it
> convenient for common usages, sys.stdout.write() provides raw access to
> the normal output stream.
>
> Jeff Shannon
> Technician/Programmer
> Credit International
>
>
>