dolor.util.interfaces

Utilities for checking object interfaces.

is_iterable(obj)[source]

Checks if an object is iterable.

Parameters

obj

The object to check. obj is iterable if it can be used in the following expression:

for x in obj:
    pass

Returns

Whether obj is iterable.

Return type

bool

is_container(obj)[source]

Checks if an object is a container.

Parameters

obj

The object to check. obj is a container if it can be used in the following expression:

x in obj

Returns

Whether obj is a container.

Return type

bool

is_pathlike(obj)[source]

Checks if an object is pathlike.

Parameters

obj – The object to check.

Returns

Whether obj is pathlike.

Return type

bool

file_object(obj)[source]

Converts an object to a file object.

Parameters

obj (file object or bytes or bytearray) – The object to convert.