Package: d8s-lists
Democritus ListsDemocritus functions[1]for working with lists.[1] Democritus functions aresimple, effective, modular, well-tested, and well-documentedPython functions.We used8s(pronounced "dee-eights") as an abbreviation fordemocritus(you can read more about thishere).Installationpip install d8s-listsUsageYou import the library like:fromd8s_listsimport*Once imported, you can use any of the functions listed below.Functionsdefiterable_sort_by_length(iterable:Iterable[Any],**kwargs)->List[Any]:"""."""deflongest(iterable:Iterable[Any])->Any:"""."""defshortest(iterable:Iterable[Any])->Any:"""."""defflatten(iterable:Iterable[Any],level:int=None,**kwargs)->Iterator[Any]:"""Flatten all items in the iterable so that they are all items in the same list."""defhas_index(iterable:Sized,index:int)->bool:"""."""deftypes(iterable:Iterable[Any])->Iterator[Type]:"""Return a set containing the types of all items in the list_arg."""defiterable_item_of_types(iterable:Iterable[Any],item_types:Iterable[type])->bool:"""Return True if the iterable has any item that is of the item_types. Otherwise, return False."""defiterable_all_items_of_types(iterable:Iterable[Any],item_types:Iterable[type])->bool:"""Return True if all items in the iterable are of a type given in item_types. Otherwise, return False."""defiterable_has_all_items_of_type(iterable:Iterable[Any],type_arg:type)->bool:"""Return whether or not all iterable in iterable are of the type specified by the type_arg."""defdeduplicate(iterable:Iterable[Any])->Iterator[Any]:"""Deduplicate the iterable."""defcycle(iterable:Iterable[Any],length:Optional[int]=None)->Iterator[Any]:"""Cycle through the iterable as much as needed."""deftruthy_items(iterable:Iterable[Any])->Iterator[Any]:"""Return an iterable with only elements of the given iterable which evaluate to True.(see https://docs.python.org/3.9/library/stdtypes.html#truth-value-testing)"""defnontruthy_items(iterable:Iterable[Any])->Iterator[Any]:"""Return an iterable with only elements of the given iterable which evaluate to False.(see https://docs.python.org/3.9/library/stdtypes.html#truth-value-testing)"""defiterable_has_single_item(iterable:Iterable[Any])->bool:"""Return whether the iterable has a single item in it."""defiterables_are_same_length(a:Sized,b:Sized,*args:Sized,debug_failure:bool=False)->bool:"""Return whether or not the given iterables are the same lengths."""defiterables_have_same_items(a:Sequence,b:Sequence,*args:Sequence)->bool:"""Return whether iterables have identical items (considering both identity and count)."""defrun_length_encoding(iterable:Iterable[Any])->Iterator[str]:"""Perform run-length encoding on the given array.See https://en.wikipedia.org/wiki/Run-length_encoding for more details."""defiterable_count(iterable:Iterable[Any])->Dict[Any,int]:"""Count each item in the iterable."""defiterable_item_index(iterable:Sequence,item:Any)->int:"""Find the given item in the iterable. Return -1 if the item is not found."""defiterable_item_indexes(iterable:Iterable[Any],item:Any)->Iterator[int]:"""Find the given item in the iterable. Return -1 if the item is not found."""defduplicates(iterable:Sequence)->Iterator[Sequence]:"""Find duplicates in the given iterable."""defiterable_has_mixed_types(iterable:Iterable[Any])->bool:"""Return whether or not the iterable has items with two or more types."""defiterable_has_single_type(iterable:Iterable[Any])->bool:"""Return whether or not the iterable has items of only one type."""defiterable_replace(iterable:Iterable[Any],old_value:Any,new_value:Any)->Iterator[Any]:"""Replace all instances of the old_value with the new_value in the given iterable."""Development👋  If you want to get involved in this project, we have some short, helpful guides below:contribute to this project 🥇test it 🧪lint it 🧹explore it 🔭If you have any questions or there is anything we did not cover, please raise an issue and we'll be happy to help.CreditsThis package was created withCookiecutterand Floyd Hightower'sPython project template.