repr( open('/etc/motd', 'rt').read() )

Random832 random832 at fastmail.com
Mon Feb 15 09:47:22 EST 2016


On Mon, Feb 15, 2016, at 08:05, Veek. M wrote:
> What is happening with # 1 # (repr)?
> repr calls __repr__ which gives you bytes.. why does this result in \\n

When you call a function that returns a string directly in the
interpreter prompt (i.e. without print), it passes the result to repr,
which means in this case repr has been called twice.


More information about the Python-list mailing list