[Python-Dev] RE: Python on Windows chapter.

Mark Hammond MHammond@skippinet.com.au
Wed, 14 Jul 1999 15:10:38 +1000


I asked Guido to provide comments on one of the chapters in our book:

I was discussing appending the mode ("t" or "b") to the open() call

> p.10, bottom: text mode is the default -- I've never seen the 't'
> option described!  (So even if it exists, better be silent about it.)
> You need to append 'b' to get binary mode instead.

This brings up an interesting issue.

MSVC exposes a global variable that contains the default mode - ie, you can
change the default to binary. (_fmode for those with the docs)

This has some implications and questions:
* Will Guido ever bow to pressure (when it arrives :) to expose this via
the "msvcrt" module?  I can imagine where it may be useful in a limited
context.  A reasonable argument would be that, like _setmode and other MS
specific stuff, if it exists it should be exposed.

* But even if not, due to the shared CRTL, in COM and other worlds we
really cant predict what the default is.  Although Python does not touch
it, that does not stop someone else touching it.  A web-server built using
MSVC on Windows may use it?

Thus, it appears that to be 100% sure what mode you are using, you should
not rely on the default, but should _always_ use "b" or "t" on the file
mode.

Any thoughts or comments?  The case for abandoning the CRTL's text mode
gets stronger and stronger!

Mark.