[Tutor] FW: wierd replace problem

Walter Prins wprins at gmail.com
Tue Sep 14 22:05:06 CEST 2010


Roelof,

On 14 September 2010 17:35, Roelof Wobben <rwobben at hotmail.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100914/573c9c82/attachment.html>


More information about the Tutor mailing list