[docs] Bug in tutorial
1 2
bothenta at gmail.com
Thu Mar 27 01:47:13 CET 2014
Well, I think I found the problem, it was because the text warping of my
epub reader, now I switch back to pdf which is much better.
As for shortening the example, I think it could be like the following:
Pls remember the backslash always continues a physical line which would
combine the two physical line where it locates and the line below into the
same logical line.
>>> print("""\
... first line
... second line\
... still second line
... third line with no trailing newline
..."""
)
The result would be:
'first line
second line still second line
third line with no trailing newline
'
Hi,
>
> On Wed, Mar 26, 2014 at 12:11 AM, 1 2 <bothenta at gmail.com> wrote:
> > There is a bug on chapter 3.1.2 on strings
> >
> > "End of lines are automatically included in the string, but it's
> possible to
> > prevent this by adding a \at the end of the line. The following example:"
> >
> > It said to add "\" at the end of the line.
> >
> > But in the example, it added backslash at the begin of the line
>
> The example looks correct to me. Note that the backslash is at the
> beginning of the string, not the beginning of a line. Here is a
> sample session that will hopefully make things a little clearer for
> you:
>
> >>> """first line
> ... second line
> ... third line
> ... fourth line"""
> 'first line\nsecond line\nthird line\nfourth line'
> >>> print(_) # At the interactive prompt, _ is always the last
> result
> first line
> second line
> third line
> fourth line
> >>> """\
> ... first line
> ... second line
> ... third line (empty fourth line follows)
> ... """
> 'first line\nsecond line\nthird line (empty fourth line follows)\n'
> >>> print(_)
> first line
> second line
> third line (empty fourth line follows)
>
> >>> """\
> ... first line
> ... second line\
> ... still second line
> ... third line with no trailing newline\
> ... """
> 'first line\nsecond line still second line\nthird line with no
> trailing newline'
> >>> print(_)
> first line
> second line still second line
> third line with no trailing newline
>
> Basically, a '\' at the end of a physical line causes the logical line
> to continue. Does that make sense?
>
> The example above is way too long to add to the documentation, but if
> you can suggest any way to tweak the docs to make things clearer,
> please let us know!
>
> Regards,
>
> --
> Zach
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20140327/92575b31/attachment.html>
More information about the docs
mailing list