repr( open('/etc/motd', 'rt').read() )
tjreedy at udel.edu
Mon Feb 15 15:03:21 EST 2016
On 2/15/2016 8:05 AM, Veek. M wrote:
> When I do at the interpreter prompt,
> repr( open('/etc/motd', 'rt').read() )
> i get # 1 #:
When posting questions here or at Stackoverflow or elsewhere, it is a
really good idea to develop and post a 'minimal, complete, verifiable
example' that demonstrates the behavior in question. In this case, the
open and read calls are just noise. A string with a newline illustrates
your question without distraction.
>>> s = '\n'
For this question, 'at the interpreter prompt' is essential, so leaving
the >>> prompt is a good idea. I did the above with 3.5.1 also in IDLE
and got exactly the same result, which should be the case.
duplicates the collective >>> responses seen above and demonstrates, as
Random832 said, that '>>> expr' prints repr(expr).
Terry Jan Reedy
More information about the Python-list