labm8.types

Python type utilities.

labm8.types.dict_values(src)

Recursively get values in dict.

Unlike the builtin dict.values() function, this method will descend into nested dicts, returning all nested values.

Parameters:src (dict) – Source dict.
Returns:List of values.
Return type:list
labm8.types.flatten(lists)

Flatten a list of lists.

labm8.types.get_class_that_defined_method(meth)

Return the class that defines a method.

Parameters:meth (str) – Class method.
Returns:Class object, or None if not a class method.
Return type:class
labm8.types.is_dict(obj)

Check if an object is a dict.

labm8.types.is_seq(obj)

Check if an object is a sequence.

labm8.types.is_str(s)

Return whether variable is string type.

On python 3, unicode encoding is not string type. On python 2, it is.

Parameters:s – Value.
Returns:True if is string, else false.
Return type:bool
labm8.types.update(dst, src)

Recursively update values in dst from src.

Unlike the builtin dict.update() function, this method will decend into nested dicts, updating all nested values.

Parameters:
  • dst (dict) – Destination dict.
  • src (dict) – Source dict.
Returns:

dst updated with entries from src.

Return type:

dict