Strange behavior

Chris Angelico rosuav at gmail.com
Thu Jan 14 07:56:46 EST 2016


On Thu, Jan 14, 2016 at 3:03 PM, Michal Nalevanko
<michal.nalevanko at gmail.com> wrote:
> I've just installed Python 3.5.1 on my computer and came across somewhat
> strange behavior.
>
> This is a snapshot of a short code that I wrote: https://goo.gl/izYbD0
>
> Quite simple, you might say. Obviously, the program should create a new
> text file, nothing else. But do you see the numbers it had added to the
> output?
>
> Is this behavior normal or am I overlooking something? Thank you very much
> for your help.

Hi Michal!

When you work with Python interactively, the interpreter prints out
the results of expressions automatically. This doesn't happen when you
write a script, but it's often helpful with simple tinkering. The
numbers getting printed out are the returned values from the .write()
method; they're a simple check saying how much stuff got written. You
can ignore them - your file has been created correctly.

ChrisA



More information about the Python-list mailing list