is "_io.py" missing from 2.7.4 ?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Apr 8 20:20:33 EDT 2013


On Mon, 08 Apr 2013 06:12:02 -0700, dbv wrote:

> In 2.7.4, io.py shows:
> 
> import _io
> import abc
> 
> from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError,
> UnsupportedOperation,
>                  open, FileIO, BytesIO, StringIO, BufferedReader,
>                  BufferedWriter, BufferedRWPair, BufferedRandom,
>                  IncrementalNewlineDecoder, TextIOWrapper)
> 
> but, cannot find _io.py, though there is the old _pyio.py in the
> //Python27//Lib folder.


If "from _io import ..." succeeds with no error, then it is physically 
impossible for it to be missing.

To find where the _io module lives, at the interactive interpreter run 
this:

import _io
_io.__file__


Under Linux, you should get something like this:

'/usr/local/lib/python2.7/lib-dynload/_io.so'


and the equivalent under Windows.

Note that in Python 3.3, the _io module is now built-in into the 
compiler, so _io.__file__ no longer exists.


-- 
Steven



More information about the Python-list mailing list