[ python-Bugs-1738754 ] Tutorial error in 3.1.2 Strings
SourceForge.net
noreply at sourceforge.net
Mon Jun 18 04:53:48 CEST 2007
Bugs item #1738754, was opened at 2007-06-17 13:11
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1738754&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.5
>Status: Closed
>Resolution: Invalid
Priority: 5
Private: No
Submitted By: otan (otan)
>Assigned to: Neal Norwitz (nnorwitz)
Summary: Tutorial error in 3.1.2 Strings
Initial Comment:
The backslash is removed by the interpreter in this context:
>>> '"Isn\'t," she said.'
'"Isn\'t," she said.'
correct is:
>>> '"Isn\'t," she said.'
'"Isn't," she said.'
This might be confusing especially for beginners!
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2007-06-17 19:53
Message:
Logged In: YES
user_id=33168
Originator: NO
This is correct in context. If it was printed (ie, the str()), it would
be correct to remove the backslash. In this case it's taking the repr(),
so the backslash must be in there.
>>> '"Isn\'t," she said.'
'"Isn\'t," she said.'
>>> print '"Isn\'t," she said.'
"Isn't," she said.
Or more specifically:
>>> print repr('"Isn\'t," she said.')
'"Isn\'t," she said.'
>>> print str('"Isn\'t," she said.')
"Isn't," she said.
I only wish I had noticed there wasn't a print before checking in a "fix".
:-)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1738754&group_id=5470
More information about the Python-bugs-list
mailing list