[Python-bugs-list] [ python-Bugs-431060 ] print 'foo',;readline() softspace error

noreply@sourceforge.net noreply@sourceforge.net
Fri, 06 Jul 2001 07:16:15 -0700


Bugs item #431060, was opened at 2001-06-07 07:26
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=431060&group_id=5470

Category: Python Library
>Group: Not a Bug
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: print 'foo',;readline() softspace error

Initial Comment:
python 2.1 (and 1.5), intel linux and sparc solaris.

def f():
	print 'foo: ',
	sys.stdin.readline()
	print 'bar: '
f()
foo: george
 bar:

A print with trailing comma, followed by a readline
and another print, puts an extra space at the beginning
of the second printed line.  An explicit setting
of sys.stdout.softspace=0 after the first print averts
this error.

----------------------------------------------------------------------

>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-07-06 07:16

Message:
Logged In: YES 
user_id=3066

While this can be annoying, it is not really a bug, and
could only be "fixed" if we add support for some general
concept of "tieing" an input and output stream.

The problem is that the print and the readline() affect two
different file objects.  Unless the input stream which
provides the readline() method knows about the output stream
used for the print, there's no way to update the softspace
attribute on the output stream.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=431060&group_id=5470