rics.collections.misc#

Miscellaneous utility methods for collections.

Module Attributes

ArgType

ArgType generic type.

Functions

as_list(arg, excl_types)

Create a list or list-wrapping of arg.

class ArgType#

ArgType generic type.

alias of TypeVar(‘ArgType’)

as_list(arg: ArgType | Iterable[ArgType] | None = None, excl_types: tuple[type[Any]] = (<class 'str'>, )) list[ArgType][source]#

Create a list or list-wrapping of arg.

Parameters:
  • arg – An object to name.

  • excl_types – Iterable types that should be treated as single elements, such as strings.

Returns:

A list representation of arg.

Notes

For all zero-length arguments, i.e. len(arg) == 0, an empty list is returned.