Detect Linux Runlevel

Marko Rauhamaa marko at
Thu Dec 8 13:07:16 EST 2016

Tim Chase <python.list at>:

> Interesting.  I read up on and 
> but didn't notice anything there clarifying that it was unbuffered
> compared to the and functions.
> Could you point me to resources where I can learn more about the
> distinctions?

It is not explained very clearly in the documentation, but the os.*
functions are thin wrappers around the analogous C functions (system
calls or standard library functions).

There is just this allusion:

   Note that using the file descriptor directly will bypass the file
   object methods, ignoring aspects such as internal buffering of data.


The os.* facilities are ultimately documented in the Linux man pages.

File object buffering can be turned off by adding buffering=0 to the
high-level open() builtin function:

   When no buffering argument is given, the default buffering policy
   works as follows:

    * Binary files are buffered in fixed-size chunks; the size of the
      buffer is chosen using a heuristic trying to determine the
      underlying device’s “block size” and falling back on
      io.DEFAULT_BUFFER_SIZE. On many systems, the buffer will typically
      be 4096 or 8192 bytes long.


In general, system programming is best done using system programming
facilities, ie, os.*.


More information about the Python-list mailing list