On 02/22/2013 09:40 PM, Don Jennings wrote:

On Feb 22, 2013, at 9:12 PM, tutor-requ...@python.org wrote:

Message: 5
Date: Fri, 22 Feb 2013 21:03:00 -0500
From: Dave Angel <da...@davea.name>
<snip>



Did you read the beginning of that digest? It said to make sure and rename the subect line. Tutor Digest isn't much of a title. In the future, please reply to the individual message, which you can probably find as an attachment to the digest. Not only will that give you the correct subject line, but it won't break threading either.

FWIW, there is absolutely no difference between a string object created
with single quotes, one created with triple-quotes, or one created by
calling some function, or by evaluating some expression.

I beg to differ as it's bitten me on more than one occasion. As Steve pointed 
out, the triple quoted option embeds newlines. Maybe you mean something 
different than what I take your statement to mean?




The triple-quoting did not add newlines, the user of them did, probably along with extra spaces. And all the other methods of creating a string object could have newlines as well. No difference. Certainly if one does not consider the contents of the string, then one should expect surprises. If you run a triple-quoted string over more than a single line, you're deliberately and explicitly adding newlines.

If you call readline(), the string object you get back is likely to have a newline in it. But not necessarily. A programmer that doesn't consider that is setting up for a surprise.

If you have a \n in a string, you're probably going to get a newline. Even if you did something like:

    name = "c:\my\new\directory"

So if you don't consider that, you are likely to get a surprise.

Life is full of surprises; it's important to know what your literals represent.

--
DaveA
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to