Need Help Parsing From File

John Machin sjmachin at lexicon.net
Thu Dec 7 13:44:47 EST 2006


Gabriel Genellina wrote:
> At Thursday 7/12/2006 02:51, John Machin wrote:
>
> >Gabriel Genellina wrote:
> > >
> > > ftxt=open(filename,"rt")
> >
> >Never seen that done before. It's not in the docs.
>
> A remnant of my MSDOS+C background...
>
> >FWIW:
> >
> >Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
> >(Intel)] on win
> >32
> >Type "help", "copyright", "credits" or "license" for more information.
> > >>> f = open('foo.txt', 'rt')
> > >>> f = open('foo.txt', 'rs')
> > >>> f = open('foo.txt', 'ratsdroppings')
> ># Nary an exception raised, not the slightest murmur
> >
> >Is this a bug or a feature? Or is it one of those good old "unspecified
> >behaviour" cases? MSVC rtl only?
>
> The Python docs say only that the initial letter is checked. And the
> ANSI 89 C says that other characters may follow after r, r+, etc.
> "rt" is useless for an ANSI C compiler, since the default stream mode
> is "text" -on systems which differentiate between text and binary-
> and irrelevant on systems which don't do such distinction.
> (And since I got used to write "rt",

Why did you do that?
(1) Text mode is was and ever shall be the default, even with MS.
(2) Seeing we're referring to docs and standards: Microsoft C 5.0
Optimizing Compiler, Run-Time Library Reference manual says "The t
option is not part of the ANSI standard for open, but is a Microsoft
extension and should not be used where ANSI portability is required".

> you can infer something about
> *when* I began to write C programs...)

Youngster :-) 

Cheers,
John




More information about the Python-list mailing list