[Python-bugs-list] [ python-Bugs-480215 ] softspace confused in nested print
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 25 Jan 2002 02:14:36 -0800
Bugs item #480215, was opened at 2001-11-09 14:33
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=480215&group_id=5470
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Tim Peters (tim_one)
Assigned to: Nobody/Anonymous (nobody)
Summary: softspace confused in nested print
Initial Comment:
Adapted from a c.l.py report:
class C:
. def __str__(self):
. print "a"
. return "b"
print C()
The output is " a\nb\n" -- note the surprising leading
space. This is because PRINT_ITEM forces softspace to
1 *before* converting the output item (so softspace is
1 when we get into __str__, despite that nothing yet
has been written).
----------------------------------------------------------------------
>Comment By: Michael Hudson (mwh)
Date: 2002-01-25 02:14
Message:
Logged In: YES
user_id=6656
In my bid to reduce the number of unassigned bugs I say: so
what?
print is magical, maybe too magical, but I thought the
consensus was that it's not worth changing. Having
side-effects in __str__ methods is gross anyway.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=480215&group_id=5470