Skip to content

pop

Source

Hook for removing (pop) a key from a dict or item from a list based on index.Follows python's pop

Inputs

Name Type Default Required Description
src Union[dict, str, list] True A list to remove an item from or dict to remove a key and output the result or a str with separators or list for a key path to the item operate on within the context.
src_is_key_path bool False True If the src is a list and is meant to be a key path.
item Union[str, int] None False A string for a key to remove from a dict src or integer for an index to remove from a list src.
sep str / True For string src's, a separator for key path.

Arguments

Position Argument Type
1 src Union[dict, str, list]
2 item Union[str, int]

Returns

Union[dict, list, NoneType]

Examples

Removes an item from a list

list:
  - stuff
  - things
new_list->: pop "{{list}}" 1

list:
  - stuff
  - things
new_list:
  - stuff

Removes an item from a list in place based on a path

path:
  to:
    list:
      - stuff
      - things
remove in place_>: pop path/to/list 0

path:
  to:
    list:
      - things

List pop in place expanded

path:
  to:
    list:
      - stuff
      - things
remove in place:
  _>: pop
  src: path/to/list
  item: 0

path:
  to:
    list:
      - things