Need Help Parsing From File

Gabriel Genellina gagsl-py at yahoo.com.ar
Thu Dec 7 03:15:44 EST 2006


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", you can infer something about 
*when* I began to write C programs...)


-- 
Gabriel Genellina
Softlab SRL 

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar



More information about the Python-list mailing list