[Tutor] Question on regular expressions

Terry Carroll carroll at tjc.com
Thu May 25 21:57:36 CEST 2006


On Thu, 25 May 2006, Kent Johnson wrote:

> Yes, this is a feature of print, it always inserts a newline.

Well, you can get rid of the newline by ending with a comma, but it still 
will insert spaces:

>>> for ch in "abc":
...  print ch
...
a
b
c
>>> for ch in "abc":
...  print ch,
...
a b c
>>>

I recall a way to get around that, too, but don't remember what it was.  
Your suggestion:

>  To avoid this, use sys.stdout.write() instead of print:

Is the cleanest way to go, rather than arm-wrestling with "print".




More information about the Tutor mailing list