Interactive entered code, inserts spurious numbers.

Steven D'Aprano steve at
Fri Jul 31 11:30:21 CEST 2015

On Fri, 31 Jul 2015 06:47 pm, Antoon Pardon wrote:

> That is different behaviour from python2, which gives me
> the expected result. My guess is that the write returns
> 11, being the number of characters written en that the
> interpreter, shows that each time through the loop.

In Python 3, write returns the number of characters written (or bytes
written, when in binary mode).

At the interactive interpreter, results returned but not assigned to
anything are printed.

> But is this the expected behaviour in python3? I find
> it annoying.

Yes, expected.

    dontcare = write("%2d: %6.4f\n" % (a, a * pi / frac))


More information about the Python-list mailing list