Python vs Visual Basic

Stephen Horne $$$$$$$$$$$$$$$$$ at $$$$$$$$$$$$$$$$$$$$.co.uk
Mon Oct 13 11:11:43 EDT 2003


On Mon, 13 Oct 2003 07:56:45 -0700, achrist at easystreet.com wrote:

>Alex Martelli wrote:
>> 
>> Orange Free wrote:
>> 
>> May I suggest an alternative?  Perhaps you might be satisfied with
>> generating a foo.rtf rather than foo.doc file.  Now, the RTF format
>> isn't much easier or better documented than the DOC format, but it
>> has the advantage that RTF format files are TEXT.  
>
>I just looked at some RTF's, and they contain Ascii character 10's (\n)
>not paired with Ascii character 13's (\r).  This is not a TEXT
>format file according to MS's OS's.  If you try to write this data from
>Python as a text file, you'll get the \r's inserted automatically, the
>contents of the file will change, and who knows what will result.  

I just looked at an RTF file generated by MS Word. It had standard
MS-DOS line ends.

I believe that RTF doesn't much care which line-end convention you
use. RTF is meant to be a platform independent interchange file, so I
suspect programs importing them are expected to handle all common
conventions and the programs creating them probably use whatever line
end convention is normal on that platform.

Line ends are actually mostly irrelevant in RTF files. Paragraph
breaks, for instance, are specified by the '\par' RTF command. Even if
you put a line break in the middle of a text word, it doesn't seem to
break the word up once imported into Word.

I believe the line end counts as whitespace where RTF requires
whitespace, but that is its only significance. Other than that it is
ignored. Though I haven't double checked, so don't sue me if there are
some cases where that isn't true.

Certainly in the context of Alex Martellis suggestion, the "what will
result" is basically no problems whatsoever. Well, OK, I suppose the
file size will get a few bytes shorter ;-)


-- 
Steve Horne

steve at ninereeds dot fsnet dot co dot uk




More information about the Python-list mailing list