Nodes/ComfyUI-LogicUtils/Pyobjects/List Pop
ComfyUI Node

Pyobjects/List Pop

Remove an item and get the shortened list back

By aria1th·Created 3 years ago·Updated 7 months ago· 119
Pyobjects/List Pop
  • py_list
  • *
  • LIST
index-1

Python's list.pop() does two things at once: it removes an item and hands it back to you. This node does the same, and - because a ComfyUI node can have more than one output port where a Python function can only return once - it gives you both results separately: the item you popped, and the list with that item now gone.

What it does

One required input, py_list (LIST), and one optional input, index (INT, default -1). The default matches Python's own default: -1 means "the last item," so if you don't touch the index at all, List Pop behaves like popping off the end of the list - the most common case. Set it to any other valid index to pop from a specific position instead.

Two outputs come back: the first is a wildcard * port carrying the item that got removed, and the second is the LIST port carrying what's left. This is the detail people miss most often - you have to wire both if you need both. It's easy to grab the popped item, use it, and forget the shortened list is sitting there unconnected, silently going nowhere.

Realistic use: processing a queue-like list one item at a time (pop the next one, do something with it, feed the shortened list back into another Pop for the next iteration), or just pulling the most recent item off a list you've been building with Append while keeping the rest intact for later.

The inputs and outputs that matter

  • py_list (required, LIST) - the list to pop from.
  • index (optional INT, default -1) - which position to remove. -1 is the last item, matching Python's default.
  • Outputs: * (the popped item) and LIST (the list with that item removed) - two separate ports, wire whichever ones you actually need.

Installing it

Standard install for this pack: ComfyUI Manager → search ComfyUI-LogicUtils → install → restart, or by hand with cd ComfyUI/custom_nodes && git clone https://github.com/aria1th/ComfyUI-LogicUtils then a restart. No models, no dependency weight - the pack got recommended on Reddit specifically for being lightweight when someone wanted basic logic without the overhead of a bigger node suite. There's an opt-in install hook (COMFYUI_LOGICUTILS_AUTO_INSTALL=1) with an off-switch (COMFYUI_LOGICUTILS_SKIP_INSTALL=1), though there's nothing substantial for it to install here anyway.

Where people get burned

Popping from an empty list fails - same as Python's own list.pop() on an empty list, which raises an IndexError rather than returning nothing gracefully. If your list might legitimately be empty at some point in a loop-like workflow, that's the case to guard against before wiring into Pop.

The other real trap is the two-output thing already mentioned: if you only wire the popped-item output and ignore the shortened-list output, that's fine as long as you don't also need the rest of the list downstream - but if you do need it and forget to connect it, you'll end up debugging why a later node isn't reflecting the removal, when the answer is just an unwired port. Since this pack's own documentation is thin by the author's admission, tracing exactly which output is which by name (the schema orders * before LIST) is worth doing once so you don't second-guess it every time you drop the node in.

CategoryData

Inputs (2)

NameTypeDefaultDescription
py_listLIST
indexoptINT-1

Outputs (2)

NameTypeDescription
**
LISTLIST