[Tutor] FW: wierd replace problem
Roelof Wobben
rwobben at hotmail.com
Tue Sep 14 22:10:10 CEST 2010
________________________________
> Date: Tue, 14 Sep 2010 21:05:06 +0100
> Subject: Re: [Tutor] FW: wierd replace problem
> From: wprins at gmail.com
> To: rwobben at hotmail.com
> CC: tutor at python.org
>
> Roelof,
>
> On 14 September 2010 17:35, Roelof Wobben
>> wrote:
> But how can I use the triple quotes when reading a textf-file ?
>
> To repeat what I said before, obviously not clearly enough: All the
> quoting stuff, escaping stuff, all of that ONLY APPLIES TO STRINGS/DATA
> INSIDE OF YOUR PYTHON CODE. It does NOT APPLY TO DATA INSIDE OF
> FILES! Why not to files? Because there's no ambiguity in data inside
> a file. It's understood that everything in a file is just data. By
> contrast, in Python code, quote characters have *meaning*.
> Specifically they indicate the start and end of string literals. So
> when they themselves are part of teh string you have to write them
> specially to indicate their meaning, either as closing the string, or
> as part of the string data.
>
> In a file by contrast, every character is presumed to be just a piece
> of data, and so quotes have no special inherent meaning to Python, so
> they just represent themselves and always just form part of the data
> being read from the file. Do you understand what I'm saying? If you
> have any doubt please respond so we can try to get this cleared up --
> Unless and until you realise there's a difference between data in a
> file and string literals in your python source code you're not going to
> undertand what you're doing here.
>
> Regards,
>
> Walter
I understand it but I try to understand why in a file there is this 'word python makes a "'word.
I know that a file is just data but I thought that if that data is read in a string I could work with the quoting stuff.
But im very wrong here.
Roelof
More information about the Tutor
mailing list