inject_items

privex.helpers.common.inject_items(items: list, dest_list: list, position: int) → List[str][source]

Inject a list items after a certain element in dest_list.

NOTE: This does NOT alter dest_list - it returns a NEW list with items injected after the given position in dest_list.

Example Usage:

>>> x = ['a', 'b', 'e', 'f', 'g']
>>> y = ['c', 'd']
>>> # Inject the list 'y' into list 'x' after element 1 (b)
>>> inject_items(y, x, 1)
['a', 'b', 'c', 'd', 'e', 'f', 'g']
Parameters
  • items (list) – A list of items to inject into dest_list

  • dest_list (list) – The list to inject items into

  • position (int) – Inject items after this element (0 = 1st item) in dest_list

Return List[str] injected

dest_list with the passed items list injected at position