rwskit.collections

Utilities for working with collections.

Functions

is_iterable(→ bool)

Tests if the object is iterable.

is_generator(→ bool)

Checks if the object is a generator.

get_first_non_null_value(→ Optional[Any])

Recursively try to get the first non-null value in a collection.

Module Contents

rwskit.collections_.is_iterable(obj: Any, consider_string_iterable: bool = False) bool[source]

Tests if the object is iterable.

Parameters:
  • obj (any) – An object.

  • consider_string_iterable (bool, default = False) – Whether to consider strings iterable or not.

Returns:

True if obj is iterable.

Return type:

bool

rwskit.collections_.is_generator(obj: Any) bool[source]

Checks if the object is a generator.

Parameters:

obj (any) – An object.

Returns:

True if the object is a generator.

Return type:

bool

rwskit.collections_.get_first_non_null_value(collection: Iterable) Any | None[source]

Recursively try to get the first non-null value in a collection.

This method will recursively traverse the collection until it finds a non-iterable value that is not None.

Parameters:

collection (Iterable) – The collection to retrieve the value from.

Returns:

The first non-null value in the series, if one exists, otherwise return None.

Return type:

Any, optional