This is a preview version of the DisplayLink DL-7450 Software Development Kit Documentation. The functionality that is described and made available in this version is subject to addition, removal or change without warning.

io – input/output streams

This module contains additional types of stream (file-like) objects and helper functions.

Conceptual hierarchy

Difference to CPython

The hierarchy of stream base classes is simplified compared to CPython.

Functions

io.open(name, mode='r', **kwargs)

Open a file. The builtin open() function is aliased to this function.

Classes

class io.StringIO([string])
class io.BytesIO([string])

In-memory file-like objects for input/output. StringIO is used for text-mode I/O (similar to a normal file opened with “t” modifier). BytesIO is used for binary-mode I/O (similar to a normal file opened with “b” modifier). Initial contents of file-like objects can be specified with the string parameter (should be str for StringIO or bytes for BytesIO). All the usual file methods from CPython like read(), write(), seek(), flush() and close() are available on these objects, and additionally, a following method:

getvalue()

Get the current contents of the underlying buffer which holds data.

class io.StringIO(alloc_size)
class io.BytesIO(alloc_size)

Create an empty StringIO/BytesIO object, preallocated to hold up to alloc_size number of bytes. That means that writing that amount of bytes won’t lead to reallocation of the buffer, and thus won’t hit out-of-memory situation or lead to memory fragmentation. These constructors are recommended for usage only in special cases.